Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/charmander/pqr
Runs package.json scripts more reliably, and without Node and npm overhead.
https://github.com/charmander/pqr
package-json
Last synced: about 1 month ago
JSON representation
Runs package.json scripts more reliably, and without Node and npm overhead.
- Host: GitHub
- URL: https://github.com/charmander/pqr
- Owner: charmander
- License: isc
- Created: 2017-10-19T12:02:26.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2024-09-04T00:39:15.000Z (4 months ago)
- Last Synced: 2024-10-14T03:42:06.684Z (3 months ago)
- Topics: package-json
- Language: Nim
- Homepage:
- Size: 12.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## pqr
Runs package.json scripts without Node and npm overhead.
```shellsession
$ time npm run echo test> @ echo pqr/test
> echo "test"test
real 0m0.200s
user 0m0.186s
sys 0m0.017s$ time pqr echo test
testreal 0m0.003s
user 0m0.003s
sys 0m0.000s
```### Installation
```shellsession
$ go get github.com/charmander/pqr
```### Intended incompatibilities with `npm run-script`
- pqr runs only the specified script; npm [also runs scripts with `pre` and `post` prefixes][npm-pre-post] 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][npm-prefix]: the nearest directory containing either a `package.json` or a `node_modules` after first removing all `node_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][npm-quoting]. (For example, `npm run-script script -- '\"; yes #'` will execute `yes`.)
- 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%` or `cmd` on Windows][npm-windows].
- pqr doesn’t include npm’s `node-gyp-bin` in `PATH` (because it doesn’t require npm to exist); find the directory with `npm run env dirname '$(which node-gyp)'` and run
PATH=node-gyp-bin:$PATH pqr …
for near-compatibility.### Running nested scripts with pqr
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.
[npm-pre-post]: https://github.com/npm/npm/blob/d081cc6c8d73f2aa698aab36605377c95e916224/lib/run-script.js#L158
[npm-prefix]: https://github.com/npm/npm/blob/d081cc6c8d73f2aa698aab36605377c95e916224/lib/config/find-prefix.js
[npm-quoting]: https://github.com/npm/npm/blob/d081cc6c8d73f2aa698aab36605377c95e916224/lib/run-script.js#L178
[npm-windows]: https://github.com/npm/npm/blob/d081cc6c8d73f2aa698aab36605377c95e916224/lib/utils/lifecycle.js#L237
[go-14750]: https://github.com/golang/go/issues/14750