(Deprecated! Please check out https://fig.io/ or https://github.com/antfu/ni as possible alternatives)
nprr: npm run + autocomplete π
TL;DR: install it with
$ npm i -g nprr
, run it with$ nprr
. If you want, add an alias.
Watch the video on asciinema
Nprr is an npm run
enhancer! It runs the good npm run
programmatically (through npm.run()
, not child_process.exec()
) or let you choose the script to launch with autocomplete.
- runs a script the same way
npm run
would do $ nprr
reads the package.json scripts and let you choose the script to run with autocomplete$ nprr te
filters all the scripts containingte
and lets you choose the script to run with autocomplete$ nprr test
runs directly any existing script (ex.test
)
Imagine your package.json contains the following scripts:
{
"scripts": {
"test": "...",
"test:unit": "...",
"test:e2e": "...",
"build:production": "...",
"build:staging": "...",
"commit": "..."
}
}
$ nprr
presents an autocomplete with all the available scripts$ nprr te
presents an autocomplete with all the scripts containing "te" ("test", "test:unit", "test:e2e")$ nprr test
launches directlynpm run test
All the scripts can be launched with options too, all the next examples chain op1 op2
to the executed script, just after the autocomplete (or exact match) process:
$ nprr -- op1 op2
$ nprr te -- op1 op2
$ nprr te op1 op2
$ nprr test -- op1 op2
$ nprr test op1 op2
npm i -g nprr
Yep! All the bin names are stored in /usr/local/bin
and if you open it you can find the "nprr" symlink as long as the "npm" one (and "npx", etc.). All you need to do is duplicating it by running:
$ cp -a /usr/local/bin/nprr /usr/local/bin/YOUR_SHORTCUT
(replace "YOUR_SHORTCUT" with "npr", "r" or whatever you want)
If you change your mind and you want to remove the new shortcut, do not worry: remove it by running
$ rm /usr/local/bin/YOUR_SHORTCUT
Read the dedicated article, both on Medium or dev.to.
Certainly! The script below leverages nprr and gets the arguments passed to nprr.run()
(please, do not forget to install nprr locally with npm i -D nprr
)
const nprr = require("nprr");
nprr("test").then(argv => {
console.log(argv);
});
Nprr accepts an array of strings or a string as the only argument.
Unfortunately not but I'd love to add it as soon as possible. Nprr leverages Enquirer but, at the moment, it does not allow to do that, see the related issue (and Inquirer can do that neither).
At the moment the fuzzy search is not supported. I need to investigate how it could be done with Enquirer/Inquirer.
Because "npr" has already been used on NPM.
Because "nprr" is faser to be typed compared to "npra".
Yes, it's the built-in npm-completion.
Use asciinema. If you want to generate a GIF, make the video public and convert it launching $ docker run --rm -v $PWD:/data asciinema/asciicast2gif https://asciinema.org/a/VIDEOID.json video.gif
.
The E2E tests are run directly with Travis, take a look at the .travis.yml
file.
Thanks goes to these wonderful people (emoji key):
Stefano Magni π» π π π‘ π€ |
This project follows the all-contributors specification. Contributions of any kind welcome!