sindresorhus / nano-spawn

Tiny process execution for humans — a better child_process
MIT License
444 stars 6 forks source link

Windows support #12

Closed ehmicky closed 2 months ago

ehmicky commented 2 months ago

See background comments about this in https://github.com/sindresorhus/execa/issues/1147

Windows support is important. But it also requires a fair amount of code.

We can't use node-cross-spawn because it's got too much code for our design goal of keeping this package small. Also, that package is unmaintained (see https://github.com/sindresorhus/execa/issues/578).

I would suggest the following:

ehmicky commented 2 months ago

I add a closer look at what node-cross-spawn is precisely doing and summarized it here.

Shebang support is nice but requires resolving the executable file path, read its contents, then manipulate the file/arguments. This would require too many bytes to implement. Users can work around this by specifying the runtime explicitly, e.g. node file.js instead of ./file.js.

node-cross-spawn also adds support for the PATHEXT environment variable without using shell: true. We might or might not implement it, depending on whether it can be done in just a few bytes.

However, there is one critical feature that we probably should support. Right now, on Windows, nano-spawn requires shell: true to call any Node module binary (whether installed globally or locally), including npm itself. This is quite important IMHO and we might need to add some logic to support this.