Fora's Build System.

Use crankshaft instead
Last updated 4 years ago by jeswin .
GPL-3.0+ · Repository · Bugs · Original npm · Tarball
$ cnpm install fora-build 
SYNC missed versions from official npm registry.


fora-build is a very simple build module for node.js (using ES6 generators). It prefers code over configuration and encourages you to use stuff you already know like bash commands and built-in node functions. Also monitors files for changes after the build.

Why the weird name? Because it is being developed as part of the Fora Project (


There are essentially three steps

  1. npm install 'fora-build'
  2. Write a build.js file
  3. node --harmony build.js

The build.js file

This example should help you get started. This is the same code that runs in the test/ directory.

    Configuration Section.
buildConfig = function() {
        The first task to run when the build starts.
        Let's call it "start_build". It just prints a message.
        Note: name (ie "start_build") isn't stricly required, 
        but it allows us to declare it as a dependency in another job.
    this.onStart(function*() {
        console.log("Let's start copying files...");
    }, "start_build");

        Let's create an app directory.
        We add "start_build" as a dependency, so that it runs after the message.
    this.onStart(function*() {
        console.log("Creating app directory");
        yield* exec("rm app -rf");
        yield* exec("mkdir app");
    }, "create_dirs", ["start_build"]);

        A helper function to create directories which may not exist.
        We are going to use this in tasks below.
    ensureDirExists = function*(file) {
        var dir = path.dirname(file);
        if (!fs.existsSync(dir)) {
            yield* exec("mkdir " + dir + " -p");

        Copies all text and html files into the app directory.
        Write as many methods as you want, in this example we use only one.            
    */["*.txt", "*.html"], function*(filePath) {
        var dest = filePath.replace(/^src\//, 'app/');
        yield* ensureDirExists(dest);
        yield* exec("cp " + filePath + " " + dest);
    }, "copy_files");

        A job to merge txt files and create
    this.job(function*() {
        yield* exec("cat app/somefile.txt app/anotherfile.txt app/abc.html > app/");
    }, "merge_txt_files");

        A fake server restart. Just says it did it.        
    this.job(function*() {
        console.log("Restarting the fake server .... done");
        //yield* exec(""); //.. for example
    }, "fake_server_restart");

build = require('fora-build').create({ threads: 4 }); //That's right. Things get done in parallel.    
build.configure(buildConfig, 'data'); //data is the directory where your files are.
build.start(true, function() { console.log("Build is done. But we're still monitoring."); }); //build.start(monitor files?, onComplete callback)

Maintainers (1)
Today 0
This Week 0
This Month 28
Last Day 0
Last Week 0
Last Month 56
Dependencies (3)
Dev Dependencies (2)
Dependents (0)

Copyright 2014 - 2016 © |