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

Commit

Permalink
Merge 3735042 into 86fabdc
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Jul 8, 2017
2 parents 86fabdc + 3735042 commit 8a22f33
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 2,650 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))
31 changes: 31 additions & 0 deletions bin/package.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"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"
],
"devDependencies": {
"json": "^9.0.6"
}
}
10 changes: 3 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env node
'use strict'

const Buffer = require('safe-buffer').Buffer
Expand All @@ -12,12 +11,9 @@ const which = promisify(require('which'))

const PATH_SEP = process.platform === 'win32' ? ';' : ':'

if (require.main === module) {
main(parseArgs())
}

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

0 comments on commit 8a22f33

Please sign in to comment.