Your deploy script should only run if the tests pass. Your long build should tell you when it's done, so you stop checking the tab. And when you start a server, you want to know when it's actually ready, not just started.
How do you do it?
You chain it: npm test && ./deploy.sh. Then you add ; say done at the end, and then || say failed, and the one line becomes a puzzle of &&, || and parentheses. For "ready", you watch the log until the line you're waiting for scrolls past.
With cmdbook, each of these has its own place on the command.
Here's how
1. Pre: check first. Put npm test in the command's Pre field. It runs before the main command, in the same shell. If it fails, the main command is skipped, and the run shows the test output.
2. Post: react to the result. Three fields, so you don't build the && / || yourself:
-
Post · always: runs after the command exits, whatever happened.
afplay /System/Library/Sounds/Glass.aiff -
Post · success: only when it exits with 0.
say "deployed" -
Post · failure: only when it fails, and not when you stopped it yourself.
say "deploy failed"
3. Health check: know when it's ready. Tell cmdbook what "ready" means for this command: a port that accepts connections, a URL that returns 200, or a line in the output like Server started on port. While it runs, the command shows running — healthy, or health check failed if it doesn't get there in time.
Your script stays the same. The checks and the notifications live next to it, not inside it.
All of this is in cmdbook's free plan.
Try cmdbook here: printf.app/cmdbook

Top comments (0)