-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
child_process: add windowsHide option
This commit exposes the UV_PROCESS_WINDOWS_HIDE flag in Node as a windowsHide option to the child_process methods. The option is only applicable to Windows, and is ignored elsewhere. Backport-PR-URL: #16425 Fixes: #15217 PR-URL: #15380 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
1 parent
ff25ca7
commit 81d01bc
Showing
8 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Flags: --expose_internals | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const cp = require('child_process'); | ||
const internalCp = require('internal/child_process'); | ||
const cmd = process.execPath; | ||
const args = ['-p', '42']; | ||
const options = { windowsHide: true }; | ||
|
||
// Since windowsHide isn't really observable, monkey patch spawn() to verify | ||
// the flag is being passed through correctly. spawnSync() is kind enough to | ||
// give all of the parsed inputs back in the result. | ||
const originalSpawn = internalCp.ChildProcess.prototype.spawn; | ||
|
||
internalCp.ChildProcess.prototype.spawn = common.mustCall(function(options) { | ||
assert.strictEqual(options.windowsHide, true); | ||
return originalSpawn.apply(this, arguments); | ||
}, 2); | ||
|
||
{ | ||
const child = cp.spawnSync(cmd, args, options); | ||
|
||
assert.strictEqual(child.status, 0); | ||
assert.strictEqual(child.signal, null); | ||
assert.strictEqual(child.options.windowsHide, true); | ||
assert.strictEqual(child.stdout.toString().trim(), '42'); | ||
assert.strictEqual(child.stderr.toString().trim(), ''); | ||
} | ||
|
||
{ | ||
const child = cp.spawn(cmd, args, options); | ||
|
||
child.on('exit', common.mustCall((code, signal) => { | ||
assert.strictEqual(code, 0); | ||
assert.strictEqual(signal, null); | ||
})); | ||
} | ||
|
||
{ | ||
const callback = common.mustCall((err, stdout, stderr) => { | ||
assert.ifError(err); | ||
assert.strictEqual(stdout.trim(), '42'); | ||
assert.strictEqual(stderr.trim(), ''); | ||
}); | ||
|
||
cp.execFile(cmd, args, options, callback); | ||
} |