13 releases (8 breaking)

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

#54 in Build Utils

Download history 15/week @ 2024-01-22 486/week @ 2024-02-19 79/week @ 2024-02-26 8/week @ 2024-03-04 26/week @ 2024-03-11 10/week @ 2024-04-01 161/week @ 2024-04-15

171 downloads per month

GPL-3.0-only

39KB
550 lines

nrr

Crates.io Version Crates.io Total Downloads GitHub Actions Build Workflow Status GitHub Actions Build Workflow Status GitHub License

built with nix

Minimal, blazing fast npm scripts runner.

FeaturesInstallationUsage

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, bun, and dum running a simple true script
Command Mean [ms] Min [ms] Max [ms] Relative
nrr 1.9 ± 0.1 1.7 2.3 1.00
dum 2.5 ± 0.2 2.3 3.5 1.35 ± 0.11
bun 6.9 ± 0.2 6.6 7.7 3.69 ± 0.21
yarn 304.8 ± 10.5 291.2 347.2 162.32 ± 10.13
npm 332.0 ± 17.5 314.1 421.5 176.84 ± 13.10
pnpm 511.5 ± 20.6 482.8 606.3 272.41 ± 17.91

Benchmarks run on an AWS EC2 t4g.micro instance with the command hyperfine --shell=none --warmup=5 --runs=1000 --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).

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 of nrx.exe) in your PATH, you can execute commands through the nrx 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.

Cargo

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

GitHub Releases

You can download

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

~11–22MB
~283K SLoC