-
-
Notifications
You must be signed in to change notification settings - Fork 240
Description
Being able to spawn a worker thread instead of a child process using a simple boolean option would be nice.
await execa(..., {thread: true});Unlike Worker in browsers, Node.js worker_threads includes many similar features as child processes: environment variables, stdin/stdout/stderr, argv.
Also, most of Execa's logic is actually userland, i.e. implemented by us and not borrowed from child_process.spawn(). For example, most things input/output-related (including subprocess piping), the verbose mode, etc. It would be nice to be able to re-use all of those Execa features but with a worker thread instead. I believe 90-95% of features can be re-used.
This option would imply the node: true option, since only Node.js files can be launched as threads.
Instead of returning a .subprocess property (#413), this would return a .worker property, with the Worker instead. We would try to make the properties/methods as close to .subprocess as possible, for parity.
That's a bigger feature, but this might be quite useful. What are your thoughts on this @sindresorhus?