This fixes running npx inside temporary projects (ones that have a
node_modules but don't have a package.json).
getPrefix() has useful cases:
Finds a path with a package.json, returns it.
Finds a path with a node_modules, returns it.
Finds nothing, returns the original path.
Cases 1 and 2 return a path that's useful to npx, but case 3 doesn't.
But, localBinPath() confused case 2 and 3 (by stating for a
package.json), making npx only work with case 1. That's no good.
This makes cases 1 and 2 distinct from case 3 (it just returns false
now). And localBinPath() no longer has to do any stating to
differentiate between paths and false, so it's happy. And now npx
can run without a local package.json. Yay!
This fixes running
npx
inside temporary projects (ones that have anode_modules
but don't have apackage.json
).getPrefix()
has useful cases:package.json
, returns it.node_modules
, returns it.Cases 1 and 2 return a path that's useful to
npx
, but case 3 doesn't. But,localBinPath()
confused case 2 and 3 (by stating for apackage.json
), makingnpx
only work with case 1. That's no good.This makes cases 1 and 2 distinct from case 3 (it just returns
false
now). AndlocalBinPath()
no longer has to do any stating to differentiate between paths andfalse
, so it's happy. And nownpx
can run without a localpackage.json
. Yay!Fixes https://github.com/zkat/npx/issues/104. Fixes https://github.com/babel/babel/issues/4066#issuecomment-336705199.