Allow specifying stdin (#360)

* Allow specifying stdin
This commit is contained in:
Seth Vargo
2020-04-13 13:39:42 -04:00
committed by GitHub
parent 05e39f551d
commit c4b6011310
6 changed files with 67 additions and 0 deletions

View File

@@ -30,6 +30,9 @@ export interface ExecOptions {
/** optional. How long in ms to wait for STDIO streams to close after the exit event of the process before terminating. defaults to 10000 */
delay?: number
/** optional. input to write to the process on STDIN. */
input?: Buffer
/** optional. Listeners for output. Callback functions that will be called on these events */
listeners?: {
stdout?: (data: Buffer) => void

View File

@@ -524,6 +524,14 @@ export class ToolRunner extends events.EventEmitter {
resolve(exitCode)
}
})
if (this.options.input) {
if (!cp.stdin) {
throw new Error('child process missing stdin')
}
cp.stdin.end(this.options.input)
}
})
}
}