Skip to content

Latest commit

 

History

History
115 lines (85 loc) · 2.55 KB

README.md

File metadata and controls

115 lines (85 loc) · 2.55 KB

Bake

A Bash-based Make alternative

Why?

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
}

task.succeed() {
	printf '%s\n' 'Success!'
}

In the same (or any child) 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 =================================================
Error (bake): Your 'Bakefile.sh' did not exit successfully
Stacktrace:
  -> Bakefile.sh:235 task.fail()
  -> bake:244 __bake_main()
$ echo $?
1

Prettified output is sent to standard error, so pipines works

$ bake succeed 2>/dev/null | cat
Success!

If you don't remember the tasks...

$ bake
Error (bake) No task supplied
Tasks:
  -> lint
  -> deploy
  -> fail

To sum it up, it just works

Features

  • Generates a ./bake file, for use in CI, etc.
  • Sensible set, shopt, and LANG defaults
  • Set variables à la Make: bake CC=clang build
  • Automatically cd's to directory contaning Bakefile
  • Pass -f to manually specify Bakefile
  • Dead-simple, miniscule function API (see api.md for details)
  • Built-in support for watchexec
  • Includes bundled versions of bash-term v0.6.3 and bash-core v0.12.0 (HEAD)

Installation

Brew

Coming soon...

Manual

WARNING: Manual is ONLY available on main branch and is NOT RELEASE-READY!

git clone 'https://github.com/hyperupcall/bake' ~/.bake
printf '%s\n' 'PATH="$HOME/.bake/pkg/bin:$PATH"' >> ~/.bashrc

Basalt

Not recommended, as Basalt is still Beta-quality

Use Basalt, a Bash package manager, to install this project globally

basalt global add hyperupcall/bake