Files
kotlin-fork/libraries/tools/kotlin-test-nodejs-runner/src/TeamCityMessagesFlow.ts
T
Sergey Rostov d467e4209a Gradle: Basic Kotlin NodeJS tests runner
#KT-30531 Fixed
#KT-30528 Fixed
2019-03-22 09:49:32 +03:00

23 lines
690 B
TypeScript

import {dateTimeWithoutTimeZone, newFlowId, tcEscape} from "./utils"
export type TeamCityMessageData = { [key: string]: any }
export class TeamCityMessagesFlow {
public readonly id: number;
constructor(id: number | null, private readonly send: (payload: string) => void) {
this.id = id || newFlowId()
}
sendMessage(type: string, args: TeamCityMessageData) {
args['flowId'] = this.id;
args['timestamp'] = dateTimeWithoutTimeZone();
const serializedArgs = Object
.keys(args)
.map((key) => `${key}='${tcEscape(args[key])}'`)
.join(' ');
this.send(`##teamcity[${type} ${serializedArgs}]`)
}
}