Skip to content

doc: fix return types for sync methods #58575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions doc/api/child_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,8 @@ changes:
`'/bin/sh'` on Unix, and `process.env.ComSpec` on Windows. A different
shell can be specified as a string. See [Shell requirements][] and
[Default Windows shell][]. **Default:** `false` (no shell).
* Returns: {Buffer|string} The stdout from the command.
* Returns: {Buffer|string|null} If `stdio` is `'pipe'`, the stdout from the
command, otherwise null.

The `child_process.execFileSync()` method is generally identical to
[`child_process.execFile()`][] with the exception that the method will not
Expand Down Expand Up @@ -1323,7 +1324,8 @@ changes:
**Default:** `'buffer'`.
* `windowsHide` {boolean} Hide the subprocess console window that would
normally be created on Windows systems. **Default:** `false`.
* Returns: {Buffer|string} The stdout from the command.
* Returns: {Buffer|string|null} If `stdio` is `'pipe'`, the stdout from the
command, otherwise null.

The `child_process.execSync()` method is generally identical to
[`child_process.exec()`][] with the exception that the method will not return
Expand Down Expand Up @@ -1407,8 +1409,10 @@ changes:
* Returns: {Object}
* `pid` {number} Pid of the child process.
* `output` {Array} Array of results from stdio output.
* `stdout` {Buffer|string} The contents of `output[1]`.
* `stderr` {Buffer|string} The contents of `output[2]`.
* `stdout` {Buffer|string|null} If `stdio` is `'pipe'`, the contents of
`output[1]`, otherwise null.
* `stderr` {Buffer|string|null} If `stdio` is `'pipe'`, the contents of
`output[2]`, otherwise null.
* `status` {number|null} The exit code of the subprocess, or `null` if the
subprocess terminated due to a signal.
* `signal` {string|null} The signal used to kill the subprocess, or `null` if
Expand Down
8 changes: 4 additions & 4 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -823,8 +823,8 @@ function spawn(file, args, options) {
* @returns {{
* pid: number;
* output: Array;
* stdout: Buffer | string;
* stderr: Buffer | string;
* stdout: Buffer | string | null;
* stderr: Buffer | string | null;
* status: number | null;
* signal: string | null;
* error: Error;
Expand Down Expand Up @@ -912,7 +912,7 @@ function checkExecSyncError(ret, args, cmd) {
* windowsHide?: boolean;
* shell?: boolean | string;
* }} [options]
* @returns {Buffer | string}
* @returns {Buffer | string | null}
*/
function execFileSync(file, args, options) {
({ file, args, options } = normalizeExecFileArgs(file, args, options));
Expand Down Expand Up @@ -950,7 +950,7 @@ function execFileSync(file, args, options) {
* encoding?: string;
* windowsHide?: boolean;
* }} [options]
* @returns {Buffer | string}
* @returns {Buffer | string | null}
*/
function execSync(command, options) {
const opts = normalizeExecArgs(command, options, null);
Expand Down
Loading