sindresorhus / nano-spawn

Tiny process execution for humans — a better child_process
MIT License
195 stars 4 forks source link

Remove Windows edge case #60

Closed ehmicky closed 2 weeks ago

ehmicky commented 2 weeks ago

On Windows, we need to know whether the binary is a .exe or .com file. If not, cmd.exe must be used.

To do that detection, we check for .exe or .com files within the current PATH environment variable, making a bunch of stat syscalls. If a file exists, we also make sure it is a regular file, not a directory.

So we check whether a file is a directory despite 1) having an executable name (like node), 2) ending with .exe/.com, 3) being in a directory referenced by PATH. This is quite an edge case that is very unlikely. This PR removes that to same some bytes and simplify the logic.