Micro CLI to interactively run npm & yarn scripts.
This Node
+ TypeScript
version is now deprecated and will not be maintained as I'm rewriting everything in Rust 🦀. The Rust version can be found here.
First, I wanted to practise creating public CLI packages/libraries.
Secondly, I'm lazy. Like, really lazy. I don't even like to type much. And sometimes I'm perplexed
by amount of steps required to run an npm or yarn script. Especially if you can't remember what
scripts a project even has without diving into an IDE or cat
ing (less
ing, bat
ing) a
package.json
.
Thirdly, if you seek for autocompletion, I would suggest you to use this zsh enhancement. If you are like me—read on.
You can:
- Interactively select and run scripts from
package.json
- Use different package managers: npm, pnpm or yarn
- Override default package manager (npm) via env variable
I have plans on adding support for lerna and running multiple scripts. You can check the milestones.
Node v12.18.0 or higher is required
$ npm i -g @arcdelta/sx
Just type at the root of your project:
$ sx
This will run an interactive prompt with scripts from package.json
as selectable options. You pick
one, hit Enter and that's it.
Option | Description |
---|---|
-n , --npm |
Use npm to run a script. |
-p , --pnpm |
Use pnpm to run a script. |
-y , --yarn |
Use yarn to run a script. |
-v , --version |
Output the current version. |
-h , --help |
Output help message. |
If you use yarn or pnpm instead of npm, you can instruct sx
to use it as a default
package manager by exposing a SX_PM=yarn
environment variable in your shell's rc file (.zshrc
,
.bash_profile
, etc).
This project relies only on ansi-colors.
MIT.