Skip to content

Latest commit

 

History

History
140 lines (89 loc) · 6.17 KB

README.md

File metadata and controls

140 lines (89 loc) · 6.17 KB

nrr

Crates.io Version Crates.io Total Downloads GitHub Actions Build Workflow Status GitHub Actions Test 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, node --run, bun, and dum running a simple true script
Command Mean [ms] Min [ms] Max [ms] Relative
nrr v0.9.5 1.4 ± 0.1 1.2 2.8 1.00
dum v0.1.19 2.0 ± 0.5 1.7 20.9 1.37 ± 0.37
bun v1.1.26 4.4 ± 0.8 3.6 12.6 3.06 ± 0.61
node --run v22.7.0 5.6 ± 0.3 5.1 7.3 3.90 ± 0.35
npm v10.8.2 178.5 ± 7.4 168.6 191.0 123.22 ± 10.42
yarn v4.4.1 310.7 ± 5.3 301.7 319.8 214.52 ± 16.21
pnpm v9.9.0 520.9 ± 19.0 502.3 554.8 359.61 ± 29.56

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 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:

[email protected]
$ run-s lint format:check
[email protected] 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 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 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