Skip to content
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

ChildProcess spawn ignores options param #24912

Closed
eduardbme opened this issue Dec 8, 2018 · 0 comments
Closed

ChildProcess spawn ignores options param #24912

eduardbme opened this issue Dec 8, 2018 · 0 comments

Comments

@eduardbme
Copy link
Contributor

  • Version: v9.10.1+
  • Platform: Darwin
  • Subsystem: child_process
const cp = require('child_process');

const pwd = cp.spawn('pwd', undefined, { cwd: '/' })

pwd.stdout.on('data', data => console.log(data.toString()));
admin$ pwd
/tmp
admin$ node test.js 
/tmp

I know how to fix it, just pass an empty array as a second argument, or completely skip it.

But that behavior a little bit weird, the second parameter (args) is optional, so I guessed undefined is okay for it.

When using TypeScript some IDEs suggests that undefined value could be passed (cuz param is optional) and that's why in my project I passed undefined to it and got a weird program behavior.

screen shot 2018-12-08 at 10 03 53 pm

eduardbme added a commit to eduardbme/node that referenced this issue Dec 16, 2018
spawn method ignores 3-d argument 'options' in case
the second one 'args' equals to 'undefined'.

Fixes: nodejs#24912
@Trott Trott closed this as completed in 2077007 Dec 16, 2018
MylesBorins pushed a commit that referenced this issue Dec 25, 2018
spawn method ignores 3-d argument 'options' in case
the second one 'args' equals to 'undefined'.

Fixes: #24912

PR-URL: #24913
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
refack pushed a commit to refack/node that referenced this issue Jan 14, 2019
spawn method ignores 3-d argument 'options' in case
the second one 'args' equals to 'undefined'.

Fixes: nodejs#24912

PR-URL: nodejs#24913
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
BethGriggs pushed a commit that referenced this issue Mar 14, 2019
spawn method ignores 3-d argument 'options' in case
the second one 'args' equals to 'undefined'.

Fixes: #24912

PR-URL: #24913
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant