Bake is a bash task runner
Shell
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
example
var
.app
.gitignore
bake.sh
changelog.md
readme.md

readme.md

Bake

Bake is a modular task running tool written on pure bash.

Usage

All you need is to create bake.sh into root of your project. Run bake bake:init command. It will create empty bake.sh file and bake_modules directory.

Example bakefile:

# bake.sh

# Initialize new node package
task:hello() {
    echo 'Hello'
}

task:say_hello() {
    echo 'Hello again'
}

Now you can run tasks:

bake hello # -> Hello
bake say-hello # -> Hello again

Modules

Modular system is inspired by node.js and golang it uses bake_modules directory and url based package naming. Module requires with command bake:module. Module file could contain tasks and custom functions or variables.

Install module:

bake -i "github.com/rumkin/test_module"
ls bake_modules/github.com/rumkin/test_module # -> module.sh

This command will install module into directory bake_modules/github.com/rumkin/test_module.

Example:

# bake_modules/github.com/rumkin/test_module/module.sh
rumkin:test_module:print() {
  echo "Hello world"
}

# bake.sh
bake:module "github.com/rumkin/test_module"

task:run() {
    rumkin:test_module:print # -> Hello world
}

Git modules

Git module could be started with "http://" or "https://" and one of popular repository "github.com" or "bitbucket.org"

bake -i "https://github.com/rumkin/test_module"
tree bake_modules

Output:

bake_modules/
`-- github.com
    `-- rumkin
        `-- test_module
            `-- module.sh

Local modules

Local module must starts with ".", ".." or "/" and will be installed by it's base name. Example:

bake -i ../some-bake-module
ls bake_modules # -> some-bake-module

CLI arguments

  • -l – List tasks.
  • -e [environment] – Specify environment located in bake_env/${environment}.sh or output current environment variables.
  • -i <module> – Install module
  • -v – Print bake version.
  • -h – Print bake help.

Lookup and $PWD

Bake by default looking up the directory tree and search for .bakerc then bake.sh file. After that bake switch $PWD to the project's root. Calling directory will be stored in $CWD variable.

Example:

# example/bake.sh
task:pwd() {
    echo $PWD $CWD
}

task:ls() {
    ls .
}
cd example/nest
bake pwd # -> example example/nest
bake ls # -> bake.sh nest

Environment

Environments store in bake_env directory in shell files like dev.sh. Current environment lays at .env file. To dump current environment run bake -e. To switch environment run bake -e <env>. To use environment in current call run bake -e <env> <task>.

License

MIT.