Runs package.json scripts without Node and npm overhead.
$ time npm run echo test
> @ echo pqr/test
> echo "test"
test
real 0m0.200s
user 0m0.186s
sys 0m0.017s
$ time pqr echo test
test
real 0m0.003s
user 0m0.003s
sys 0m0.000s
$ go get github.com/charmander/pqr
-
pqr runs only the specified script; npm also runs scripts with
pre
andpost
prefixes if they exist. Use[pqr prescript && ]pqr script[ && pqr postscript]
for compatibility. -
pqr uses the nearest
package.json
it finds along the current path (./package.json
,../package.json
,../../package.json
, …). npm uses a prefix consistent across all commands: the nearest directory containing either apackage.json
or anode_modules
after first removing allnode_modules
components from the end of the current path. -
pqr adds arguments to the end of script commands with
"$@"
; npm double-quotes each argument after escaping only double quotes. (For example,npm run-script script -- '\"; yes #'
will executeyes
.) -
pqr runs the script with an unmodified environment; npm adds several of its own strings. (See
npm run-script env
.) -
pqr requires
sh
; npm will use%ComSpec%
orcmd
on Windows. -
pqr doesn’t include npm’s
node-gyp-bin
inPATH
(because it doesn’t require npm to exist); find the directory withnpm run env dirname '$(which node-gyp)'
and runPATH=node-gyp-bin:$PATH pqr …
for near-compatibility.
Create an npm wrapper that delegates to pqr if its first argument is run-script
or run
, and the original npm otherwise; add it to your PATH
before the original npm.