Git Product home page Git Product logo

bake's Introduction

Bake

Simple Bash build/project utility in the style of rake.

Installation

Use basher, a package manager for shell scripts and functions.

basher install dylanmei/bake

Usage

Display all tasks

bake

Run build task

bake build

Run archive task with output param

bake archive output=dist

Example Bakefile

PATH=node_modules/coffee-script/bin:$PATH

function private {
    echo in private
}


#. Builds the project
function build {
    # ensures clean is called only once
    invoke clean
    bake_ok building ...
}


#. Cleans the project
function clean {
    bake_ok "cleaning ..."
    private
}


#. Compiles coffee scripts
function coffee {
    outdated build src || return 0
    coffee -c -o build src
    bake_ok "coffe" "compiled"
}


function on_task_not_found {
    echo "Task not found $1"
}

Rules

  • bake searches the current and parent directories for a Bakefile to run.
  • Tasks are defined as normal Bash functions.
  • A task description is simply a comment that starts with #. and precedes a function.

Functions

Prints a red error message.

bake_error <action> <description>

example: bake_error "compiling" "src/lib/test.coffee"

Prints a plain message.

bake_log <action> <description>

example: bake_log "bake" "Processing bakefile..."

Prints a green ok message.

bake_ok <action> <descsription>

example: bake_ok "compiling" "compiled src/lib/test.js"

Prints a cyan info message.

bake_info <action> <description>

example: bake_info "bake" "built project in 700ms"

Invokes a task only once.

invoke <function_name>

example: invoke "clean"

Determines if target is older than reference, returning 1 if outdated.

outdated <target> <reference>

examples:

outdated build src || return 1          # skip rest of task
outdated build src && invoke "compile"  # compile if outdated

Run a dynamic task when task $1 is not found. For example, to run a test as the first argument to bake, add this to Bakefile

function on_task_not_found {
    [[ -f test/$1.js ]] && mocha test/$1.js && return 0
    return 1
}

bake's People

Contributors

dylanmei avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.