Skip to content
This repository has been archived by the owner on Jul 6, 2019. It is now read-only.

Commit

Permalink
feat(npx): create a new binary for standalone publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Jul 8, 2017
1 parent 643f58e commit da5a3b7
Show file tree
Hide file tree
Showing 12 changed files with 3,068 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/node_modules
/.nyc_output
/test/cache
npx.1
libnpx.1
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
bin: bin/README.md bin/npx.1 bin/package.json bin/node_modules

bin/README.md: README.md
cp $< $@

bin/npx.1: libnpx.1
cat $< | sed s/libnpx/npx/ > $@

libnpx.1: README.md
npm run docs

bin/package.json: package.json bin/package.template.json
cat bin/package.template.json | json -e "this.version = '$$(cat package.json | json version)'" > $@
json -I -f $@ -e "this.dependencies.libnpx = '^$$(cat $@ | json version)'"

bin/node_modules: bin/package.json
cd bin && npm i

clean:
rm -rf bin/README.md bin/npx.1 bin/package.json bin/node_modules bin/package-lock.json libnpx.1

.PHONY: clean
5 changes: 5 additions & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/README.md
/npx.1
/package.json
/package-lock.json
/node_modules
8 changes: 8 additions & 0 deletions bin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env node

const npx = require('libnpx')
const path = require('path')

const NPM_PATH = path.join(__dirname, 'node_modules', '.bin', 'npm')

npx(npx.parseArgs(process.argv, NPM_PATH))
28 changes: 28 additions & 0 deletions bin/package.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "npx",
"description": "execute npm package binaries",
"main": "index.js",
"bin": "index.js",
"files": [
"./*.js",
"./npx.1"
],
"keywords": [
"npm",
"npm exec",
"shell",
"scripts",
"npm bin",
"cli"
],
"author": "Kat Marchán <kzm@sykosomatic.org>",
"license": "CC0-1.0",
"dependencies": {
"npm": "^5.1.0",
"libnpx": ""
},
"bundleDependencies": [
"npm",
"libnpx"
]
}
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const which = promisify(require('which'))
const PATH_SEP = process.platform === 'win32' ? ';' : ':'

module.exports = npx
module.exports.parseArgs = parseArgs
function npx (argv) {
const shell = argv['shell-auto-fallback']
if (shell || shell === '') {
Expand Down
Loading

0 comments on commit da5a3b7

Please sign in to comment.