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

[WIP] Next major spawn-wrap version #77

Closed
wants to merge 45 commits into from
Closed

Conversation

demurgos
Copy link
Contributor

@demurgos demurgos commented Oct 9, 2018

While working on code coverage, I updated spawn-wrap to be more reliable, easier to use and provide more features.

This PR corresponds to the end result I reached. It is not intended to be merged immediately but should serve as a reference point. I'll break it down to smaller PRs and send them progressively.

Highlights:

  • The lib no longer requires to globally patch the internals. It's still available but discouraged: you can use an isolated child_process API with wrappers. This allows to run multiple processes concurrently with different wrappers.

  • The API was simplified to easily use a wrapper main module and pass some data to it. I checked all the dependent packages to see how the lib is used: this is basically what it boils down to. You can still pass arbitrary flags or environment variables but it's no longer the default API.

  • Various refactoring to simplify the code: less mutations, newer syntax, type annotations (catched a few bugs).

This is a large change to introduce a proper separation between the creation of the shim directory and the wrapped functions. It is the first stepped to support local wrapping.

Notable changes:
- Creation of an additional Windows cmd shim if the base name of the executable is not `node`.
- Expose object-based API as `spawnWrap.wrapGlobal`
- The shim root is now a proper directory, not a "prefix"
The new wrapper API replaces the possibility of setting `args` and
`env` with a `wrapper` path and `data` object. It also exposes a
new wrapper mode enabling spawning the child process in its own
subprocess.
Also rename `applyContextOnGlobal` to `patchInternalsWithContext`
- Use `shimScript` in Node munger (instead of `shimExecutable`).
- Wait for the streams to close before ending the TCP sockets used for observable spawns.
The lib was accidentally using `fromArray` instead of `from`.
@coreyfarrell
Copy link
Member

I'm unsure if anything from this PR is not already merged but I'm closing as I think any changes still required would need to be submitted as separate PR's.

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 this pull request may close these issues.

None yet

2 participants