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

Commit da5a3b7

Browse files
committed
feat(npx): create a new binary for standalone publishing
1 parent 643f58e commit da5a3b7

File tree

12 files changed

+3068
-46
lines changed

12 files changed

+3068
-46
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/node_modules
22
/.nyc_output
33
/test/cache
4-
npx.1
4+
libnpx.1

Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
bin: bin/README.md bin/npx.1 bin/package.json bin/node_modules
2+
3+
bin/README.md: README.md
4+
cp $< $@
5+
6+
bin/npx.1: libnpx.1
7+
cat $< | sed s/libnpx/npx/ > $@
8+
9+
libnpx.1: README.md
10+
npm run docs
11+
12+
bin/package.json: package.json bin/package.template.json
13+
cat bin/package.template.json | json -e "this.version = '$$(cat package.json | json version)'" > $@
14+
json -I -f $@ -e "this.dependencies.libnpx = '^$$(cat $@ | json version)'"
15+
16+
bin/node_modules: bin/package.json
17+
cd bin && npm i
18+
19+
clean:
20+
rm -rf bin/README.md bin/npx.1 bin/package.json bin/node_modules bin/package-lock.json libnpx.1
21+
22+
.PHONY: clean

bin/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/README.md
2+
/npx.1
3+
/package.json
4+
/package-lock.json
5+
/node_modules

bin/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env node
2+
3+
const npx = require('libnpx')
4+
const path = require('path')
5+
6+
const NPM_PATH = path.join(__dirname, 'node_modules', '.bin', 'npm')
7+
8+
npx(npx.parseArgs(process.argv, NPM_PATH))

bin/package.template.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "npx",
3+
"description": "execute npm package binaries",
4+
"main": "index.js",
5+
"bin": "index.js",
6+
"files": [
7+
"./*.js",
8+
"./npx.1"
9+
],
10+
"keywords": [
11+
"npm",
12+
"npm exec",
13+
"shell",
14+
"scripts",
15+
"npm bin",
16+
"cli"
17+
],
18+
"author": "Kat Marchán <kzm@sykosomatic.org>",
19+
"license": "CC0-1.0",
20+
"dependencies": {
21+
"npm": "^5.1.0",
22+
"libnpx": ""
23+
},
24+
"bundleDependencies": [
25+
"npm",
26+
"libnpx"
27+
]
28+
}

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const which = promisify(require('which'))
1212
const PATH_SEP = process.platform === 'win32' ? ';' : ':'
1313

1414
module.exports = npx
15+
module.exports.parseArgs = parseArgs
1516
function npx (argv) {
1617
const shell = argv['shell-auto-fallback']
1718
if (shell || shell === '') {

0 commit comments

Comments
 (0)