mysticatea / npm-run-all

A CLI tool to run multiple npm-scripts in parallel or sequential.
MIT License
5.72k stars 240 forks source link

Run any command without having to create a script for it #170

Closed fregante closed 1 year ago

fregante commented 5 years ago

I use npm-run-all to run multiple commands in parallel, but currently the commands can only be npm scripts. This is usually fine if you need these commands directly accessible (e.g. npm run test:style) but sometimes I just wish I could run simple commands directly:

run-p "test:*" "&tsc"
# where &tsc just runs the `tsc` command
blakek commented 5 years ago

I really like this idea.

I'd like to propose using something other than & mainly for the double-meaning it has in bash-like terminals.

We have a bash script we use that essentially takes arguments like this:

run-p 'test:*' 'lint' --exec 'tsc' --exec 'echo "another shell command"'

To me, the intentions are more clear and is similar to the pattern used in options like --parallel and --serial. Just throwing out what we do as an implementation option!

fregante commented 5 years ago

You’re right about &, but $tsc or $ tsc would also make sense.

The latter can already be added if you have an npm script named $ with command bash -s (or something like that)

TehShrike commented 5 years ago

Aye, with this run script:

"$": "npm run --",

you can then do

run-p "test:*" "$ tsc"

I believe that adding new mystery syntax to npm-run-all would be an out-of-scope complication.

fregante commented 5 years ago

What if npm-run-all simply had a default $ script? I think that would be easy to implement and explain.

The point here would be to avoid adding further scripts to your own package-json

tkrotoff commented 4 years ago

Would be nice to support this:

"clean": "rm -rf build coverage",
"clean:all": "npm run clean && rm -rf node_modules package-lock.json"
"lint": "tsc && eslint . '**/*.{js,jsx,ts,tsx}'"

Concurrently supports it:

"clean": "rm -rf build coverage",
"clean:all": "concurrently npm:clean 'rm -rf node_modules package-lock.json'"
"lint": "concurrently tsc \"eslint . '**/*.{js,jsx,ts,tsx}'\""
fregante commented 1 year ago

I switched to concurrently for this use case