It always defaults to use the builtin cp.spawn function (even on Windows), you can pass your own function if you want to.
It does not take over control flow: it is your responsibility to exit the parent process once the child is closed.
Other comments:
I converted the lib to Typescript (for documentation). I also converted the tests to make sure the types work fine.
I completed the test suite to reach 100% coverage.
From a semver point of view, this is a major version.
I update the dependencies.
Discussions:
Maybe provide a way to automatically kill the parent process like in the original function?
Migrating from the original function to fg.spawn should be relatively easy. For the moment I marked it as deprecated, I don't think it should be removed immediately (especially since it's known to work fine with nyc). Not sure what you think about it.
This PR is part of the effort to improve Node's support for code coverage (see discussion on
c8
).This PR exposes two new functions to support foreground childs:
proxy(parent, child)
to start forwarding between two existing processes.spawn(file, args, options)
as a replacement for the original functions allowing you to passspawn
options.The original API is still there. The only breaking change is dropping support for unmaintained Node versions (require Node 6+).
The new
spawn
function would allow to pass the env NODE_V8_COVERAGE variable directly in c8. There are a few other changes:cp.spawn
function (even on Windows), you can pass your own function if you want to.Other comments:
Discussions:
Maybe provide a way to automatically kill the parent process like in the original function?
Migrating from the original function to
fg.spawn
should be relatively easy. For the moment I marked it asdeprecated
, I don't think it should be removed immediately (especially since it's known to work fine withnyc
). Not sure what you think about it.Closes tapjs/foreground-child#13
Closes tapjs/foreground-child#14
Closes tapjs/foreground-child#15
Closes tapjs/foreground-child#16
Closes tapjs/foreground-child#17
Closes tapjs/foreground-child#18
Closes tapjs/foreground-child#19