zkat / npx

execute npm package binaries (moved)
https://github.com/npm/npx
Other
2.63k stars 105 forks source link

feat(local): use local directory-like specs as-is, without installing #48

Closed zkat closed 7 years ago

zkat commented 7 years ago

This PR implements the local script handling described in #49. I think this essentially covers the most-expected alternatives in each situation. It's DWIMy for sure, but relatively safe. In the end, any of this behavior can be bypassed by using more explicit commands (that is, npx node ./foo or npx bash ./foo instead of npx ./foo).

The main thing this is trying to address is a regular issue I'd run into where I'd do something like $ npx ./some-dir/foo with the intention of having foo see all the $PATH stuff npx does. But instead, it would try to install ./some-dir/foo as a local dep, symlinking and everything. To make matters more confusing, this would work just as expected if you happened to pass in a -p <pkg> argument, because that would prevent the usual argument parsing from happening. While local directory deps are technically installable packages, I think literally no one ever actually wants $ npx ./foo to install anything -- and if they do want to install a local dep like that, they can just do $ npx -p ./foo foo.