Make ChildProcessWithoutNullStreams a ChildProcess

This commit is contained in:
khai96_ 2019-03-29 16:14:19 +07:00
parent 372efcb075
commit 0237165eb1
2 changed files with 20 additions and 1 deletions

View File

@ -79,7 +79,7 @@ declare module "child_process" {
}
// return this object when stdio option is undefined or not specified
interface ChildProcessWithoutNullStreams {
interface ChildProcessWithoutNullStreams extends ChildProcess {
stdin: Writable;
stdout: Readable;
stderr: Readable;

View File

@ -302,6 +302,25 @@ async function testPromisify() {
expectNonNull(childProcess.spawn('command', ['a', 'b', 'c'], { stdio: [undefined, undefined, undefined] }));
expectNonNull(childProcess.spawn('command', ['a', 'b', 'c'], { stdio: [null, null, null] }));
expectNonNull(childProcess.spawn('command', ['a', 'b', 'c'], { stdio: ['pipe', 'pipe', 'pipe'] }));
function expectChildProcess (cp: childProcess.ChildProcess): void {
return undefined;
}
expectChildProcess(childProcess.spawn('command'));
expectChildProcess(childProcess.spawn('command', {}));
expectChildProcess(childProcess.spawn('command', { stdio: undefined }));
expectChildProcess(childProcess.spawn('command', { stdio: 'pipe' }));
expectChildProcess(childProcess.spawn('command', { stdio: [undefined, undefined, undefined] }));
expectChildProcess(childProcess.spawn('command', { stdio: [null, null, null] }));
expectChildProcess(childProcess.spawn('command', { stdio: ['pipe', 'pipe', 'pipe'] }));
expectChildProcess(childProcess.spawn('command', ['a', 'b', 'c']));
expectChildProcess(childProcess.spawn('command', ['a', 'b', 'c'], {}));
expectChildProcess(childProcess.spawn('command', ['a', 'b', 'c'], { stdio: undefined }));
expectChildProcess(childProcess.spawn('command', ['a', 'b', 'c'], { stdio: 'pipe' }));
expectChildProcess(childProcess.spawn('command', ['a', 'b', 'c'], { stdio: [undefined, undefined, undefined] }));
expectChildProcess(childProcess.spawn('command', ['a', 'b', 'c'], { stdio: [null, null, null] }));
expectChildProcess(childProcess.spawn('command', ['a', 'b', 'c'], { stdio: ['pipe', 'pipe', 'pipe'] }));
}
{
process.stdin.setEncoding('utf8');