13 releases (7 breaking)

new 0.8.1 Feb 24, 2024
0.7.0 Feb 21, 2024
0.3.1 Dec 25, 2023
0.2.0 Nov 25, 2023

#90 in Build Utils

Download history 41/week @ 2023-11-20 8/week @ 2023-11-27 4/week @ 2023-12-04 2/week @ 2023-12-11 34/week @ 2023-12-18 41/week @ 2023-12-25 8/week @ 2024-01-01 2/week @ 2024-01-08 1/week @ 2024-01-15 118/week @ 2024-01-22 46/week @ 2024-01-29 12/week @ 2024-02-05 67/week @ 2024-02-12 881/week @ 2024-02-19

1,032 downloads per month

GPL-3.0-only

29KB
380 lines

nrr

Minimal, blazing fast npm scripts runner.

Features

Performance

nrr initializes and resolves scripts way faster than package managers. It achieves this by providing the largest feature coverage possible while keeping it simple and performant.

Benchmark of nrr, npm, yarn, pnpm, bun, and dum running a simple echo script
Command Mean [ms] Min [ms] Max [ms] Relative
nrr 6.1 ± 0.3 5.6 8.2 1.17 ± 0.09
dum 5.2 ± 0.3 4.9 6.1 1.00
bun 7.8 ± 0.3 7.3 9.0 1.50 ± 0.10
yarn 152.7 ± 0.9 151.0 154.8 29.39 ± 1.51
npm 162.2 ± 1.3 159.9 164.8 31.21 ± 1.62
pnpm 223.8 ± 2.7 220.4 231.3 43.07 ± 2.27

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' '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).

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.

Script listing

Running nrr without any arguments 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 .

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.

Cargo

$ cargo install nrr
$ cargo install --git https://github.com/ryanccn/nrr.git

Usage

$ nrr dev
sveltekit-project@0.0.1
$ vite dev

  VITE v5.0.12  ready in 10 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help

License

GPLv3

Dependencies

~8–19MB
~242K SLoC