zkat / npx

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

Hash out wtf `npx ./foo` commands do #49

Closed zkat closed 7 years ago

zkat commented 7 years ago

There's a particular corner case with npx usage that hasn't been quite specced out to satisfaction: local directory specifiers.

note: directory in npm-package-arg lingo includes regular directories as well as any files that don't end in .tar, .tgz, or .tar.gz. I'll be using that terminology here, with specific disambiguation as necessary.

The biggest problem is that there's several different situations where these specifiers can pop up, and we need to know what to actually do with them. I'll put a table here with the current + proposed behavior for the various situations, and hopefully we can come up with something useful here.

I definitely consider the current behavior to be buggy because I think literally no one wants what npx does for this right now.

command current behavior do this instead
npx ./pkgdir npm i -g ./pkgdir && pkgdir node ./pkgdir/${pkg.bin or pkg.main or index.js}
npx ./otherdir npm i -g ./otherdir && otherdir Error: executing random directories makes no sense
npx ./foo.bin npm i -g ./foo.bin && foo.bin ./foo.bin
npx ./foo.js npm i -g ./foo.js && foo.js node ./foo.js
npx ./foo (foo has #!/usr/bin/env node) npm i -g ./foo && foo node ./foo
npx -p pkg ./whatever npm i -g pkg && ./whatever Exactly the same as above, but with an npm i -g pkg first.