Skip to content

Commit 420d8af

Browse files
committed
child_process: change windowsHide default to true
This is likely the default that more Windows users are expecting. PR-URL: #21316 Refs: libuv/libuv#1878 Refs: #21314 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 99e6ecb commit 420d8af

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
lines changed

doc/api/child_process.md

+24-6
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ exec('"my script.cmd" a b', (err, stdout, stderr) => {
131131
<!-- YAML
132132
added: v0.1.90
133133
changes:
134+
- version: REPLACEME
135+
pr-url: https://github.com/nodejs/node/pull/21316
136+
description: The `windowsHide` option now defaults to `true`.
134137
- version: v8.8.0
135138
pr-url: https://github.com/nodejs/node/pull/15380
136139
description: The `windowsHide` option is supported now.
@@ -153,7 +156,7 @@ changes:
153156
* `uid` {number} Sets the user identity of the process (see setuid(2)).
154157
* `gid` {number} Sets the group identity of the process (see setgid(2)).
155158
* `windowsHide` {boolean} Hide the subprocess console window that would
156-
normally be created on Windows systems. **Default:** `false`.
159+
normally be created on Windows systems. **Default:** `true`.
157160
* `callback` {Function} called with the output when process terminates.
158161
* `error` {Error}
159162
* `stdout` {string|Buffer}
@@ -232,6 +235,9 @@ lsExample();
232235
<!-- YAML
233236
added: v0.1.91
234237
changes:
238+
- version: REPLACEME
239+
pr-url: https://github.com/nodejs/node/pull/21316
240+
description: The `windowsHide` option now defaults to `true`.
235241
- version: v8.8.0
236242
pr-url: https://github.com/nodejs/node/pull/15380
237243
description: The `windowsHide` option is supported now.
@@ -251,7 +257,7 @@ changes:
251257
* `uid` {number} Sets the user identity of the process (see setuid(2)).
252258
* `gid` {number} Sets the group identity of the process (see setgid(2)).
253259
* `windowsHide` {boolean} Hide the subprocess console window that would
254-
normally be created on Windows systems. **Default:** `false`.
260+
normally be created on Windows systems. **Default:** `true`.
255261
* `windowsVerbatimArguments` {boolean} No quoting or escaping of arguments is
256262
done on Windows. Ignored on Unix. **Default:** `false`.
257263
* `shell` {boolean|string} If `true`, runs `command` inside of a shell. Uses
@@ -375,6 +381,9 @@ The `shell` option available in [`child_process.spawn()`][] is not supported by
375381
<!-- YAML
376382
added: v0.1.90
377383
changes:
384+
- version: REPLACEME
385+
pr-url: https://github.com/nodejs/node/pull/21316
386+
description: The `windowsHide` option now defaults to `true`.
378387
- version: v8.8.0
379388
pr-url: https://github.com/nodejs/node/pull/15380
380389
description: The `windowsHide` option is supported now.
@@ -408,7 +417,7 @@ changes:
408417
done on Windows. Ignored on Unix. This is set to `true` automatically
409418
when `shell` is specified. **Default:** `false`.
410419
* `windowsHide` {boolean} Hide the subprocess console window that would
411-
normally be created on Windows systems. **Default:** `false`.
420+
normally be created on Windows systems. **Default:** `true`.
412421
* Returns: {ChildProcess}
413422

414423
The `child_process.spawn()` method spawns a new process using the given
@@ -669,6 +678,9 @@ configuration at startup.
669678
<!-- YAML
670679
added: v0.11.12
671680
changes:
681+
- version: REPLACEME
682+
pr-url: https://github.com/nodejs/node/pull/21316
683+
description: The `windowsHide` option now defaults to `true`.
672684
- version: v8.8.0
673685
pr-url: https://github.com/nodejs/node/pull/15380
674686
description: The `windowsHide` option is supported now.
@@ -702,7 +714,7 @@ changes:
702714
* `encoding` {string} The encoding used for all stdio inputs and outputs.
703715
**Default:** `'buffer'`.
704716
* `windowsHide` {boolean} Hide the subprocess console window that would
705-
normally be created on Windows systems. **Default:** `false`.
717+
normally be created on Windows systems. **Default:** `true`.
706718
* `shell` {boolean|string} If `true`, runs `command` inside of a shell. Uses
707719
`'/bin/sh'` on UNIX, and `process.env.ComSpec` on Windows. A different
708720
shell can be specified as a string. See [Shell Requirements][] and
@@ -731,6 +743,9 @@ arbitrary command execution.**
731743
<!-- YAML
732744
added: v0.11.12
733745
changes:
746+
- version: REPLACEME
747+
pr-url: https://github.com/nodejs/node/pull/21316
748+
description: The `windowsHide` option now defaults to `true`.
734749
- version: v8.8.0
735750
pr-url: https://github.com/nodejs/node/pull/15380
736751
description: The `windowsHide` option is supported now.
@@ -763,7 +778,7 @@ changes:
763778
* `encoding` {string} The encoding used for all stdio inputs and outputs.
764779
**Default:** `'buffer'`.
765780
* `windowsHide` {boolean} Hide the subprocess console window that would
766-
normally be created on Windows systems. **Default:** `false`.
781+
normally be created on Windows systems. **Default:** `true`.
767782
* Returns: {Buffer|string} The stdout from the command.
768783

769784
The `child_process.execSync()` method is generally identical to
@@ -785,6 +800,9 @@ metacharacters may be used to trigger arbitrary command execution.**
785800
<!-- YAML
786801
added: v0.11.12
787802
changes:
803+
- version: REPLACEME
804+
pr-url: https://github.com/nodejs/node/pull/21316
805+
description: The `windowsHide` option now defaults to `true`.
788806
- version: v8.8.0
789807
pr-url: https://github.com/nodejs/node/pull/15380
790808
description: The `windowsHide` option is supported now.
@@ -826,7 +844,7 @@ changes:
826844
done on Windows. Ignored on Unix. This is set to `true` automatically
827845
when `shell` is specified. **Default:** `false`.
828846
* `windowsHide` {boolean} Hide the subprocess console window that would
829-
normally be created on Windows systems. **Default:** `false`.
847+
normally be created on Windows systems. **Default:** `true`.
830848
* Returns: {Object}
831849
* `pid` {number} Pid of the child process.
832850
* `output` {Array} Array of results from stdio output.

doc/api/cluster.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,9 @@ values are `'rr'` and `'none'`.
698698
<!-- YAML
699699
added: v0.7.1
700700
changes:
701+
- version: REPLACEME
702+
pr-url: https://github.com/nodejs/node/pull/21316
703+
description: The `windowsHide` option now defaults to `true`.
701704
- version: v9.5.0
702705
pr-url: https://github.com/nodejs/node/pull/18399
703706
description: The `cwd` option is supported now.
@@ -732,7 +735,7 @@ changes:
732735
number. By default each worker gets its own port, incremented from the
733736
master's `process.debugPort`.
734737
* `windowsHide` {boolean} Hide the forked processes console window that would
735-
normally be created on Windows systems. **Default:** `false`.
738+
normally be created on Windows systems. **Default:** `true`.
736739

737740
After calling `.setupMaster()` (or `.fork()`) this settings object will contain
738741
the settings, including the default values.

lib/child_process.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ exports.execFile = function execFile(file /* , args, options, callback */) {
221221
gid: options.gid,
222222
uid: options.uid,
223223
shell: options.shell,
224-
windowsHide: !!options.windowsHide,
224+
windowsHide: options.windowsHide !== false,
225225
windowsVerbatimArguments: !!options.windowsVerbatimArguments
226226
});
227227

@@ -529,7 +529,7 @@ var spawn = exports.spawn = function spawn(/* file, args, options */) {
529529
file: opts.file,
530530
args: opts.args,
531531
cwd: options.cwd,
532-
windowsHide: !!options.windowsHide,
532+
windowsHide: options.windowsHide !== false,
533533
windowsVerbatimArguments: !!options.windowsVerbatimArguments,
534534
detached: !!options.detached,
535535
envPairs: opts.envPairs,
@@ -563,6 +563,8 @@ function spawnSync(/* file, args, options */) {
563563

564564
options.stdio = _validateStdio(options.stdio || 'pipe', true).stdio;
565565

566+
options.windowsHide = options.windowsHide !== false;
567+
566568
if (options.input) {
567569
var stdin = options.stdio[0] = util._extend({}, options.stdio[0]);
568570
stdin.input = options.input;

test/parallel/test-child-process-spawnsync-shell.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ assert.strictEqual(env.stdout.toString().trim(), 'buzz');
6666
assert.strictEqual(opts.options.shell, shell);
6767
assert.strictEqual(opts.options.file, opts.file);
6868
assert.deepStrictEqual(opts.options.args, opts.args);
69-
assert.strictEqual(opts.options.windowsHide, undefined);
69+
assert.strictEqual(opts.options.windowsHide, true);
7070
assert.strictEqual(opts.options.windowsVerbatimArguments,
7171
windowsVerbatim);
7272
});

0 commit comments

Comments
 (0)