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

can't pass execPath or execArgs when forking #22

Open
ctrombley opened this issue Dec 5, 2017 · 1 comment
Open

can't pass execPath or execArgs when forking #22

ctrombley opened this issue Dec 5, 2017 · 1 comment

Comments

@ctrombley
Copy link

This would be useful for scenarios where the child process needs to use a different runtime than the parent.

From the docs for child_process.fork:

By default, child_process.fork() will spawn new Node.js instances using the process.execPath of the parent process. The execPath property in the options object allows for an alternative execution path to be used.

This can be accomplished easily by plumbing these two params through the passed opts. I'd like to submit a PR but first I'd like some input from the maintainers on the testing approach:

  • I could include node binaries for various platforms and cpu architectures in the test folder, sniff os and choose the correct one to point at with execPath, then verify process.execPath from the child process. This seems like overkill.
  • I could symlink system node into the test folder with fs.symlink(process.execPath, newPath), point execPath to symlinked node, then verify process.execPath from the child process. The symlink would then be deleted on test completion.
  • I could mock child_process with mock-require, mockery, proxyquire, rewire, etc.
  • Any other suggestions?
ctrombley added a commit to ctrombley/respawn that referenced this issue Dec 5, 2017
ctrombley added a commit to ctrombley/respawn that referenced this issue Dec 5, 2017
ctrombley added a commit to ctrombley/respawn that referenced this issue Dec 5, 2017
@MrCheater
Copy link

+1

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

No branches or pull requests

2 participants