18 releases (8 breaking)
0.9.5 | Aug 19, 2024 |
---|---|
0.9.4 | Jul 26, 2024 |
0.9.3 | Jun 25, 2024 |
0.8.1 | Feb 24, 2024 |
0.2.0 | Nov 25, 2023 |
#442 in Development tools
48KB
696 lines
nrr
Minimal, blazing fast npm scripts runner.
Features • Installation • Usage
Features
Performance
nrr initializes and resolves scripts way faster than other package managers and script runners. It achieves this by providing the largest feature coverage possible while keeping it simple and performant.
Benchmark of nrr
, npm
, yarn
, pnpm
, node --run
, bun
, and dum
running a simple true
script
Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
---|---|---|---|---|
nrr |
2.2 ± 0.3 | 1.9 | 7.7 | 1.00 |
dum |
2.7 ± 0.2 | 2.4 | 5.2 | 1.22 ± 0.17 |
bun |
7.1 ± 0.3 | 6.5 | 10.3 | 3.21 ± 0.40 |
node --run |
41.6 ± 1.8 | 39.3 | 49.1 | 18.80 ± 2.35 |
npm |
261.7 ± 17.1 | 245.5 | 292.2 | 118.36 ± 15.91 |
yarn |
305.7 ± 14.6 | 295.2 | 343.9 | 138.28 ± 17.52 |
pnpm |
502.7 ± 10.7 | 489.8 | 522.9 | 227.40 ± 27.12 |
Benchmarks run on an AWS EC2 t4g.micro
instance with the command hyperfine --shell=none --warmup=5 --output=pipe --export-markdown=benchmark.md 'npm run dev' -n 'npm' 'yarn run dev' -n 'yarn' 'pnpm run dev' -n 'pnpm' 'node --run dev' -n 'node --run' 'bun run dev' -n 'bun' 'dum run dev' -n 'dum' 'nrr dev' -n 'nrr'
Package and script metadata display
nrr provides a better-looking display of package details and the command being run than most, and also prints this information to stderr
instead of stdout
like some of the package managers do (erroneously).
Command execution
On top of the standard script runner functionality that runs your scripts in package.json
, nrr can also execute arbitrary commands in your npm package environments! You can use the nrr exec
and nrr x
commands to execute commands, similar to how npx
or pnpm exec
works (but faster, of course).
Do note, however, that nrr cannot run commands from remote packages! That feature falls within the purview of package managers, which nrr is not.
[!TIP]
If you create a symlink that has a name of
nrx
(or, on Windows, a hard link that has a name ofnrx.exe
) in yourPATH
, you can execute commands through thenrx
binary without using a subcommand!
Script listing
Running nrr without any arguments or running the nrr list
subcommand will try to find any packages in the current working directory and its ancestors, and list the scripts available from them, both name and command.
Tooling compatibility
nrr has compatibility functionality that patches npm_execpath
so that tools like npm-run-all2
use it instead of package managers for running sub-scripts.
[!WARNING]
This may cause unexpected behavior when
npm_execpath
is used for non-script running purposes, so open an issue if you encounter any bugs.
When running nested scripts with nrr, nrr has specialized behavior that prints extra information while staying minimal and performant:
sveltekit-project@0.0.1
$ run-s lint format:check
sveltekit-project@0.0.1 lint
$$ eslint .
Spelling suggestions
If you mistype a script name (e.g. buils
instead of build
), nrr will intelligently suggest the right script to run in the error message using the Jaro similarity algorithm from the strsim
crate.
Installation
Nix
Add the overlay or package from the github:ryanccn/nrr
flake to your own system flake. Alternatively, install the package declaratively:
$ nix profile install 'github:ryanccn/nrr#nrr'
nrr is also available in Nixpkgs as nixpkgs#nrr
.
Installer
This installer script works on Linux and macOS and downloads binaries from GitHub Releases, falling back to cargo install
if a prebuilt binary cannot be found.
$ curl --proto '=https' --tlsv1.2 -fsSL https://nrr.ryanccn.dev | sh
Cargo
nrr supports cargo-binstall, which downloads a binary if possible from GitHub Releases instead of compiling the crate from source.
$ cargo binstall nrr
If you do want to compile from source, install with Cargo directly:
$ cargo install nrr
Or if you want to stay on the bleeding edge, install with Cargo from the Git repository:
$ cargo install --git https://github.com/ryanccn/nrr.git
GitHub Releases
You can download binaries pre-compiled for Linux, macOS, and Windows from the latest GitHub Release. Linux binaries are statically linked to musl; Windows binaries require MSVC.
Usage
$ nrr dev
$ nrr run dev
$ nrx eslint --help
$ nrr x eslint --help
$ nrr exec eslint --help
$ nrr
$ nrr list
This section provides an overview of nrr's command-line functionality. For more options and information, run nrr --help
!
License
GPLv3
Dependencies
~13–24MB
~363K SLoC