open-cli-tools / concurrently

Run commands concurrently. Like `npm run watch-js & npm run watch-less` but better.
https://www.npmjs.com/package/concurrently
MIT License
7.15k stars 234 forks source link

Teardown commands #500

Closed gustavohenke closed 3 months ago

gustavohenke commented 3 months ago

Introduces a --teardown flag to pass commands that execute when every input command exits.

$ concurrently --teardown "echo bye" "echo hey"
[0] hey
[0] echo hey exited with code 0
--> Running teardown command "echo bye"
bye
--> Teardown command "echo bye" exited with code 0

As you can see, teardown commands have no prefixing.

The flag can also be specified multiple times:

$ concurrently --teardown "echo bye" --teardown "echo real bye" "echo hey"
[0] hey
[0] echo hey exited with code 0
--> Running teardown command "echo bye"
bye
--> Teardown command "echo bye" exited with code 0
--> Running teardown command "echo real bye"
real bye
--> Teardown command "echo real bye" exited with code 0

Teardown commands also don't affect concurrently's exit code (unless it fails to spawn):

$ concurrently --teardown "exit 1" "echo hey"
[0] hey
[0] echo hey exited with code 0
--> Running teardown command "exit 1"
--> Teardown command "exit 1" exited with code 1

$ echo $?
0

Closes #472

coveralls commented 3 months ago

Coverage Status

coverage: 98.677% (-0.5%) from 99.208% when pulling 2fb4ed1d6f213adce92a8363e54cb8c100e38096 on teardown into aa338acdaa0ed7f973e360c21c62e59919292a8b on main.

FezVrasta commented 3 months ago

Thanks for the feature! Can't wait to try it

FezVrasta commented 2 months ago

When can we expect a new release with this?

gustavohenke commented 2 months ago

Hey! I had been working on a few other breaking changes - just shipped it as a major version. Check out the release notes: https://github.com/open-cli-tools/concurrently/releases/tag/v9.0.0

FezVrasta commented 2 months ago

Thanks!