mask
mask copied to clipboard
✨ Concurrently run multiple commands in parallel via single command definition
@jakedeichert This is such a elegant step up from package.json
scripts, you my friend are awesome!
Problem
Concurrently run multiple commands in parallel via one single mask
command definition.
Example
Using npm-run-all --parallel
in my package.json
"scripts": {
"watch": "del dist; npm-run-all --silent --parallel watch:*",
"watch:nodemon": "wait-for-change dist/index.js && delay 0.1 && nodemon dist/index.js",
"watch:tsc": "tsc --watch --preserveWatchOutput",
},
I've tried all the alternative's at the bottom of your README.md
and I haven't been able to find something that has implemented this feature.
So far mask
is the best I've come across, then just
shortly after.
Thanks friend! =]
Hey! Glad you're enjoying mask. just
was one of my inspirations :)
So one option you have available is starting all your commands with bash in the background using &
.
Here's a simple example:
## runall
~~~bash
$MASK run server & $MASK run client & $MASK run database
~~~
However, this gets a bit tricky... exiting mask will not close these background processes for you. There's ways to handle these background tasks like using bash traps but it becomes pretty verbose in my experience.
I personally would love a rust-based version of concurrently which is what I usually use for node projects. It's been on my todo list for awhile to make a rust version of that, but i'm not sure it directly falls into the scope of mask.
I'd want someone to build a cli/lib separately first, and then integrate that into mask so we can run tasks in parallel without users having to install another tool manually.
@jacobdeichert it would be better with wait
in the end.
## runall
~~~bash
$MASK run server & $MASK run client & $MASK run database & wait
~~~
However, this gets a bit tricky... exiting mask will not close these background processes for you. There's ways to handle these background tasks like using bash traps but it becomes pretty verbose in my experience.
For handling this case it's better to start another bash process inside bash process.
~~~bash
bash -c '$MASK run server & $MASK run client & $MASK run database & wait'
~~~
So when bash subprocess would be killed, it will automatically kill his child processes. Didn't try this, just a suggestion. And yes, it looks ugly
p.s. For single-binary version of concurrently you could try my tool: https://github.com/slavaGanzin/await. It's written in C, so I think it's not what you are looking for