istanbuljs / spawn-wrap

Wrap all spawned Node.js child processes by adding environs and arguments ahead of the main JavaScript file argument.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support use of `-e` flag.

jamestalmage opened this issue · comments

See: avajs/ava#815

Specifically: avajs/ava#815 (comment)

This is because that PR makes use of the -e flag to fork a child process. Use of the -e flag causes spawn-wrap to disable wrapping that particular process.

It seems entirely possible that spawn-wrap could support the -e flag when detected by using the vm module, or maybe just simply by using eval.

@jamestalmage I like this idea, definitely an edge-case that it would be nice for spawn-wrap to handle.

So, what arguments would spawn-wrap pass to the wrapping script if node -e 'console.log("foo")' were invoked, for example?

This module knows nothing about what "wrapping" is involved. Probably the best solution would be to have some function that is passed into the call to spawnWrap() to mutate -e and -p code before passing to the node binary?

Oh, but that won't work, will it? Because it has to survive different child processes, of course, duh. (I helped write this module, but forget how it works sometimes.)

Maybe just some option to say "invoke -e/-p arguments using the script as well, and trust that we'll handle it"?