run-behind
v0.0.3
Published
Run one command interactively in the foreground, while other commands run in the background.
Downloads
491
Readme
run-behind
Run one command interactively in the foreground, while other commands run in the background.
Use cases:
- Running linting and typechecking while writing commit messages, instead of after or before like with git hooks
- Probably others, but commits is the reason I wrote this for
Installation
yarn add run-behind --dev
# or
npm install run-behind --save-dev
Usage
yarn run-behind <foreground-command> <background-command-1> <background-command-2> ... <background-command-n>
Example: shared with your team in package.json
// ...
scripts: {
"lint": "eslint src --ext .js,.ts --cache",
"typecheck": "tsc --noEmit --incremental",
"commit": "run-behind git-cz 'yarn lint' 'yarn typecheck'"
}
// ...
Example: just for you
Install globally:
npm install -g run-behind
Add an alias to ~/.zshrc
or equivalent for easy usage
alias gc=run-behind git-cz 'yarn lint --quiet' 'yarn typecheck --pretty'
Tips
If you want to get back to your terminal without waiting for the tasks to end, just hit ctrl-c.
Things will be commmited even if the background command fail. It's not a bug, it's a feature. You can use git commit --amend
if it turns out something failed.
Setting up caching for the commands will make the experience a lot better:
eslint
: just add--cache
to the commandtsc
: use--incremental
jest
: usually caching is set up by default, you can add--onlyChanged
to only run relevant tests