npm / node-which

Like which(1) unix command. Find the first instance of an executable in the PATH.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fails when using bash on windows.

airtonix opened this issue · comments

When using /bin/sh on windows (like with Cmder), the path separator in $PATH is : not ; so nothing is ever resolved unless it lives in the cwd.

So because node-which is used by pretty much every node tool, it causes a frustratingly large amount of problems for people who want to use a sane shell other than cmd.exe, the primary being npm.

It boils down to this line:

https://github.com/isaacs/node-which/blob/master/which.js#L6

How should the module decide if it's supposed to use : or ; to separate the PATH?

Just came across this, it seems like all UNIX cmds export a OSTYPE environment variable. Apprently cygwin reports cygwin and mingw reports msys on Windows. The variable is not defined in the Windows cmd.exe.

Would you consider detecting the platform based on that variable?