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

[Windows] File extension always in capital letters

Avaray opened this issue · comments

Should be like that?

Example:
...\0.20.2\hugo.EXE
...\go1.8\bin\go.EXE
...\atom\bin\atom.CMD

^ this is console.log from my app. I didn't check CLI.

Edit:
I was trying to find source of problem in code of node-which.
Changing line 29 in which.js file did nothing.
pathExtExe = (opt.pathExt || process.env.PATHEXT || '.exe;.cmd;.bat;.com')

Edit:
I was playing more with that line 29.
It seems problem is related to process.env.PATHEXT and probably to Windows OS.
My temporary fix for that is to change that line to look like this:
pathExtExe = (opt.pathExt || '.exe;.cmd;.bat;.com' || process.env.PATHEXT)

Your suggested change makes it not respect the PATHEXT environment variable at all, because '.exe;.cmd;.bat;.com' will always be truthy.

which will return the extensions in the format of the path extension option that it receives (either from the options object, or from the environment). Since Windows filesystems are case-insensitive, this is usually fine.