-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
lib: allow custom names for spawned processes #7696
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -347,7 +347,11 @@ function normalizeSpawnArguments(file /*, args, options*/) { | |
} | ||
} | ||
|
||
args.unshift(file); | ||
if (typeof options.argv0 === 'string') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. given that this is read-only now, perhaps simply doing an existence check is enough? e.g. args.unshift(options.argv0 ? options.argv0 : file); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jasnell There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ha! sorry... totally misread that :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, I had mistakenly read that code... nevermind me ;-) |
||
args.unshift(options.argv0); | ||
} else { | ||
args.unshift(file); | ||
} | ||
|
||
var env = options.env || process.env; | ||
var envPairs = []; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
require('../common'); | ||
const assert = require('assert'); | ||
const cp = require('child_process'); | ||
|
||
// This test spawns itself with an argument to indicate when it is a child to | ||
// easily and portably print the value of argv[0] | ||
if (process.argv[2] === 'child') { | ||
console.log(process.argv0); | ||
return; | ||
} | ||
|
||
const noArgv0 = cp.spawnSync(process.execPath, [__filename, 'child']); | ||
assert.strictEqual(noArgv0.stdout.toString().trim(), process.execPath); | ||
|
||
const withArgv0 = cp.spawnSync(process.execPath, [__filename, 'child'], | ||
{argv0: 'withArgv0'}); | ||
assert.strictEqual(withArgv0.stdout.toString().trim(), 'withArgv0'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/_Note:/_Note*:
For this one and the next. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every other "Note" in the file currently italicizes the whole note ( https://github.com/nodejs/node/blame/master/doc/api/child_process.md#L26, https://github.com/nodejs/node/blame/master/doc/api/child_process.md#L39, https://github.com/nodejs/node/blame/master/doc/api/child_process.md#L188 etc). I'm happy to change this one instance if you want, but should it really be inconsistent with the rest of the file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, no worries. I'll go through and fix those in a separate PR :-)