nsx is command-line interface which allows you to run a npm script by:
- its full name (
compile); - the first letters (
compforcompile); - a shortened alias (
bdforbuild:dev).
If the name can't be matched to a single script, a prompt will asked you to desired script to run.
You can pass arguments to the script without any additional --.
With node previously installed:
npm install @zokugun/nsx
nsx l --fix # run: npm lint -- --fix| Option | Default | Description |
|---|---|---|
-c, --confirm |
false |
Confirm before running the selected script. |
-p, --path |
"." |
Path to the folder containing package.json. |
-s, --separator |
":" |
The separator for shortened alias. |
nsx supports several handy ways to refer to scripts:
- Full name: call the script by its full npm script name.
nsx compileruns thecompilescript.
- Prefix matching: type the first letters of the script name.
nsx compcan matchcompileif it's unambiguous.
- Shortened alias: an alias composed of the first letter of each part of the script name (parts are split by a separator).
- By default the separator includes
:and-(for examplebuild:dev→bd). - The
-s, --separatoroption lets you change which characters are considered separators for alias generation. - Example:
nsx bdmatchesbuild:devwhen the aliasbdis unique.
- By default the separator includes
- Special patterns supported for matching:
a..z(four characters with two dots): matches scripts starting withaand ending withz.foo#bar#baz(hash#used between fragments): treated asfoo.*bar.*bazand matched anywhere in the script name.
You can run a single script, a sequence of scripts (serie), or multiple scripts in parallel.
Separate requests with a comma ,.
Examples:
nsx build,lint,testnsx b,l,tnsx "build --prod,lint --fix"(each request can have its own arguments)nsx b,'l --fix'
Use a trailing $ on a request to continue to the next request even if that request fails, for example:
nsx "build$,lint"(ifbuildfails the serie continues tolint)
Separate requests with a plus +.
Examples:
nsx build+testnsx b+tnsx "build --prod+test --watch"nsx b+'test --watch'
When running in parallel, each script is started concurrently and their results are reported individually.
When using multiple requests or arguments containing spaces, quote the whole query so the shell passes it as a single argument.
Examples:
nsx "build --prod,lint --fix"nsx "build --prod+test --watch"
These matching rules make it quick to run scripts using short forms, aliases, and combined series/parallel requests.
Support this project by becoming a financial contributor.
| ko-fi.com/daiyam | |
| liberapay.com/daiyam/donate | |
| paypal.me/daiyam99 |
Copyright © 2025-present Baptiste Augrain
Licensed under the MIT license.