A Bash-based Make alternative
Make is not meant to be used as a task runner. Just and scripts-to-rule-them-all help, but I wanted a simpler, more portable, and streamlined solution
It's simple: write a Bakefile.sh script:
#!/usr/bin/env bash
task.lint() {
prettier "**/*.{js,css}"
eslint '.'
stylelint "**/*.css"
}
task.deploy() {
yarn build
git commit -m v0.1.0 ... && git tag v0.1.0 ...
gh release ...
}
task.fail() {
printf '%s\n' "$1"
false
}In the same directory:
$ bake deploy
-> RUNNING TASK 'deploy' =================================
yarn run v1.22.17
...
<- DONE ==================================================When there is a failure...
$ bake fail 'WOOF'
-> RUNNING TASK 'docs' ===================================
WOOF
Error (bake): Your 'Bakefile.sh' did not exit successfully
-> Bakefile.sh:17 __bake_trap_err()
-> bake:117 task.fail()
-> bake:123 main()
$ echo $?
1If you don't remember the tasks...
$ bake
Error (bake) No task supplied
Tasks:
-> lint
-> deploy
-> failTo sum it up, it just works
- Generates a
./bakefile, for use in CI, etc. - Stacktrace,
set,shopt,LANGboilerplate all set up - Dead-simple, miniscule function API (only
die(),error(),warn(), andinfo()) POSIXcompliant- Automatically
cd's to directory contaning shell script
Use Basalt, a Bash package manager, to install this project globally
basalt global add hyperupcall/bake