diff --git a/index.d.ts b/index.d.ts index 81ad662a9..da9dc5af7 100644 --- a/index.d.ts +++ b/index.d.ts @@ -10,7 +10,6 @@ declare namespace execa { | 'inherit' | Stream | number - | null | undefined; interface CommonOptions { @@ -45,7 +44,7 @@ declare namespace execa { @default 'pipe' */ - readonly stdio?: 'pipe' | 'ignore' | 'inherit' | ReadonlyArray; + readonly stdio?: 'pipe' | 'ignore' | 'inherit' | readonly StdioOption[]; /** Prepare child to run independently of its parent process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached). @@ -284,11 +283,7 @@ declare namespace execa { interface ExecaChildPromise { catch( - onRejected?: - | (( - reason: ExecaError - ) => ResultType | PromiseLike) - | null + onRejected?: (reason: ExecaError) => ResultType | PromiseLike ): Promise | ResultType>; /** @@ -340,12 +335,12 @@ declare const execa: { */ ( file: string, - arguments?: ReadonlyArray, + arguments?: readonly string[], options?: execa.Options ): execa.ExecaChildProcess; ( file: string, - arguments?: ReadonlyArray, + arguments?: readonly string[], options?: execa.Options ): execa.ExecaChildProcess; (file: string, options?: execa.Options): execa.ExecaChildProcess; @@ -362,12 +357,12 @@ declare const execa: { */ stdout( file: string, - arguments?: ReadonlyArray, + arguments?: readonly string[], options?: execa.Options ): Promise; stdout( file: string, - arguments?: ReadonlyArray, + arguments?: readonly string[], options?: execa.Options ): Promise; stdout(file: string, options?: execa.Options): Promise; @@ -382,12 +377,12 @@ declare const execa: { */ stderr( file: string, - arguments?: ReadonlyArray, + arguments?: readonly string[], options?: execa.Options ): Promise; stderr( file: string, - arguments?: ReadonlyArray, + arguments?: readonly string[], options?: execa.Options ): Promise; stderr(file: string, options?: execa.Options): Promise; @@ -449,12 +444,12 @@ declare const execa: { */ sync( file: string, - arguments?: ReadonlyArray, + arguments?: readonly string[], options?: execa.SyncOptions ): execa.ExecaSyncReturnValue; sync( file: string, - arguments?: ReadonlyArray, + arguments?: readonly string[], options?: execa.SyncOptions ): execa.ExecaSyncReturnValue; sync(file: string, options?: execa.SyncOptions): execa.ExecaSyncReturnValue; diff --git a/index.js b/index.js index 684989253..9899d2c48 100644 --- a/index.js +++ b/index.js @@ -69,7 +69,7 @@ function handleArgs(command, args, options) { } function handleInput(spawned, input) { - if (input === null || input === undefined) { + if (input === undefined) { return; } diff --git a/index.test-d.ts b/index.test-d.ts index 23c06591b..e89d9661d 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -61,7 +61,7 @@ execa('unicorns', {stdio: 'pipe'}); execa('unicorns', {stdio: 'ignore'}); execa('unicorns', {stdio: 'inherit'}); execa('unicorns', { - stdio: ['pipe', 'ipc', 'ignore', 'inherit', process.stdin, 1, null, undefined] + stdio: ['pipe', 'ipc', 'ignore', 'inherit', process.stdin, 1, undefined] }); execa('unicorns', {detached: true}); execa('unicorns', {uid: 0}); @@ -84,7 +84,6 @@ execa('unicorns', {stdin: 'ignore'}); execa('unicorns', {stdin: 'inherit'}); execa('unicorns', {stdin: process.stdin}); execa('unicorns', {stdin: 1}); -execa('unicorns', {stdin: null}); execa('unicorns', {stdin: undefined}); execa('unicorns', {stderr: 'pipe'}); execa('unicorns', {stderr: 'ipc'}); @@ -92,7 +91,6 @@ execa('unicorns', {stderr: 'ignore'}); execa('unicorns', {stderr: 'inherit'}); execa('unicorns', {stderr: process.stderr}); execa('unicorns', {stderr: 1}); -execa('unicorns', {stderr: null}); execa('unicorns', {stderr: undefined}); execa('unicorns', {stdout: 'pipe'}); execa('unicorns', {stdout: 'ipc'}); @@ -100,7 +98,6 @@ execa('unicorns', {stdout: 'ignore'}); execa('unicorns', {stdout: 'inherit'}); execa('unicorns', {stdout: process.stdout}); execa('unicorns', {stdout: 1}); -execa('unicorns', {stdout: null}); execa('unicorns', {stdout: undefined}); execa('unicorns', {windowsVerbatimArguments: true}); diff --git a/readme.md b/readme.md index fd7931075..3dccd8581 100644 --- a/readme.md +++ b/readme.md @@ -162,7 +162,7 @@ Returns the same result object as [`child_process.spawnSync`](https://nodejs.org ### options -Type: `Object` +Type: `object` #### cwd @@ -173,7 +173,7 @@ Current working directory of the child process. #### env -Type: `Object`
+Type: `object`
Default: `process.env` Environment key-value pairs. Extends automatically from `process.env`. Set `extendEnv` to `false` if you don't want this. @@ -193,7 +193,7 @@ Explicitly set the value of `argv[0]` sent to the child process. This will be se #### stdio -Type: `string[]` `string`
+Type: `string | string[]`
Default: `pipe` Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration. @@ -218,7 +218,7 @@ Sets the group identity of the process. #### shell -Type: `boolean` `string`
+Type: `boolean | string`
Default: `false` If `true`, runs `command` inside of a shell. Uses `/bin/sh` on UNIX and `cmd.exe` on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows. @@ -247,7 +247,7 @@ Preferred path to find locally installed binaries in (use with `preferLocal`). #### input -Type: `string` `Buffer` `stream.Readable` +Type: `string | Buffer | stream.Readable` Write some input to the `stdin` of your binary.
Streams are not allowed when using the synchronous methods. @@ -268,7 +268,7 @@ Keep track of the spawned process and `kill` it when the parent process exits. #### encoding -Type: `string` `null`
+Type: `string | null`
Default: `utf8` Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `null`, then `stdout` and `stderr` will be a `Buffer` instead of a string. @@ -296,28 +296,28 @@ Largest amount of data in bytes allowed on `stdout` or `stderr`. #### killSignal -Type: `string` `number`
+Type: `string | number`
Default: `SIGTERM` Signal value to be used when the spawned process will be killed. #### stdin -Type: `string` `number` `Stream` `undefined` `null`
+Type: `string | number | Stream | undefined`
Default: `pipe` Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio). #### stdout -Type: `string` `number` `Stream` `undefined` `null`
+Type: `string | number | Stream | undefined`
Default: `pipe` Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio). #### stderr -Type: `string` `number` `Stream` `undefined` `null`
+Type: `string | number | Stream | undefined`
Default: `pipe` Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio). diff --git a/test.js b/test.js index ffd98bdb1..07a3b0180 100644 --- a/test.js +++ b/test.js @@ -76,7 +76,7 @@ test('do not include `stderr` and `stdout` in errors when set to `inherit`', asy }); test('do not include `stderr` and `stdout` in errors when `stdio` is set to `inherit`', async t => { - await t.throwsAsync(execa('fixtures/error-message.js', {stdio: [null, 'inherit', 'inherit']}), {message: NO_NEWLINES_REGEXP}); + await t.throwsAsync(execa('fixtures/error-message.js', {stdio: [undefined, 'inherit', 'inherit']}), {message: NO_NEWLINES_REGEXP}); }); test('do not include `stdout` in errors when set to `inherit`', async t => { @@ -213,7 +213,7 @@ test('input option can be a Buffer - sync', t => { test('opts.stdout:ignore - stdout will not collect data', async t => { const {stdout} = await execa('stdin', { input: 'hello', - stdio: [null, 'ignore', null] + stdio: [undefined, 'ignore', undefined] }); t.is(stdout, undefined); }); diff --git a/test/stdio.js b/test/stdio.js index e51fc7d8e..e02a32911 100644 --- a/test/stdio.js +++ b/test/stdio.js @@ -22,7 +22,6 @@ function macro(t, input, expected) { macro.title = (providedTitle, input) => providedTitle || util.inspect(input, {colors: true}); test(macro, undefined, undefined); -test(macro, null, undefined); test(macro, {stdio: 'inherit'}, 'inherit'); test(macro, {stdio: 'pipe'}, 'pipe');