| 28 | * Program created from a subprocess. |
| 29 | */ |
| 30 | export class SubprocessProgram implements IProgram { |
| 31 | public readonly stopped: Promise<IStopMetadata>; |
| 32 | private killed = false; |
| 33 | |
| 34 | constructor(private readonly child: ChildProcess, private readonly logger: ILogger) { |
| 35 | this.stopped = new Promise((resolve, reject) => { |
| 36 | child.once('exit', code => resolve({ killed: this.killed, code: code || 0 })); |
| 37 | child.once('error', error => reject({ killed: this.killed, code: 1, error })); |
| 38 | }); |
| 39 | } |
| 40 | |
| 41 | public gotTelemetery() { |
| 42 | // no-op |
| 43 | } |
| 44 | |
| 45 | public stop(): Promise<IStopMetadata> { |
| 46 | this.killed = true; |
| 47 | killTree(this.child.pid, this.logger); |
| 48 | return this.stopped; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * A no-op program that never stops until stop() is called. Currently, we use |
nothing calls this directly
no outgoing calls
no test coverage detected