Code Monkey home page Code Monkey logo

bake's Introduction

Bake

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

Not trying to reinvent wheel. Most node project Makefiles are just Bash scripts.

Installation

npm install bake-bash

Usage

Display tasks

bake

Run task

bake <task>

Example Bakefile

function private {
    echo in private
}

#. Builds the project
function build {
    # ensures clean is called only once
    bake-invoke "clean"
    bake-ok building ...
    # clean will not run again
    bake-invoke "clean"
}

#. Cleans the project
function clean {
    bake-ok "cleaning ..."
    private
}

#. Renders hello-template.sh
function render-template {
    bake-ok "compiling template ..."
    bake-render-template hello-template.sh | cat
    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> <description>

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.

bake-invoke <function_name>

example: bake-invoke "clean"

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

bake-outdated <target> <reference>

examples:

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

Renders a heredoc file template

bake-render-template template.sh > newfile.txt

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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

bake's Issues

Off topic: are you the owner of the "sex" package?

Hello ๐Ÿ‘‹

Sorry but I couldn't find a better way to contact you.

Do you own the sex package on NPM? If so I'm currently writing a little package that basically implements a safe subset of JavaScript, which is meant to be a way for users and extensions to write some safe boolean conditions basically, if you use vscode it's basically intended to parse "when" expressions used for defining shortcuts. Since it's meant to implement "safe expressions" I thought "sex" might be a funny name for it.

If you are the owner of sex, and don't intend to use it for anything in the future, would you consider transferring ownership of that name to me, so that I can use it for this?

You'd basically just have to execute this command in the terminal:

npm owner add fabiospampinato sex

Thanks a lot,
Fabio.

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.