-
-
Notifications
You must be signed in to change notification settings - Fork 543
Description
Pretty sure we have a bug in our execArgv logic. It works only if there are not any other node flags in the execArgv array.
Impact for users:
This affects child_process.fork(), since it uses execArgv to create a similar child runtime.
For example, child_process.fork() fails if node is launched node --no-warnings ./node_modules/ts-node/dist/bin ./index.ts
With the fix, child_process.fork() will automatically preserve node flags and ts-node hooks
To test, create a script that spawns a child that spawns a grandchild. In the grandchild, inspect process.execArgv and process.argv
Run it like this:
node --no-warnings ./dist/bin.js --cwd-mode ./spawner.js
--no-warnings can be any node flag that is not understood by ts-node. --cwd-mode can be any ts-node flag that is not understood by node.
The bug is that we're prepending our modifications to the execArgv array; we should be appending them instead.