GithubHelp home page GithubHelp logo

wikunia / bit-runner Goto Github PK

View Code? Open in Web Editor NEW

This project forked from miguelcastillo/bit-runner

0.0 3.0 0.0 109 KB

JS Task Runner that's easily configured to run complex sequences of tasks in nodejs.

License: MIT License

JavaScript 100.00%

bit-runner's Introduction

bit-runner

JS Task Runner that's easily configured to run complex sequences of tasks.

The underlying engine is bit loader to provide the transformation workflow.

Summary

bit runner's primary goal is to executes tasks. But the pipeline that executes these tasks is optimaized to reduce I/O operations by piping data from one task to another.

So, what is a task? A task is a sequence of actions that are executed to process your assests. You define what these actions are. An action can be to simply add use strict; to your JavaScript.

A task can also sepecify dependencies on other tasks. This allows you to define a uniform task sequence that executes as a single unit, where the output from one task is piped to the next task in the sequence to reduce unnecessary I/O.

An important feature of the ability to set dependencies is that you can piece together complex sequences of micro tasks - tasks that do small jobs. When a task is executed by the cli, its execution sequence is completely independent from other tasks' execution sequence. For example, you could run bitrunner build, and that task will run completely independent from bitrunner release, even if they have common task dependencies and they are executed simultaneously. This allows for elegant compositions of sequences of micro tasks.

Quick note: A task is what bit runner executes. Actions is what a task executes. Bit runner executes a sequence of tasks, and a task executes a sequence of actions.

Oversimplified illustration of a task sequence

  • Task: read from disk
    • Action: read file1.js
  • Task: transpile
  • Task: build
    • Action: add use strict
    • Action: add # sourceURL
    • Action: load dependencies
  • Task: minify

In all that sequence, there was only one read from disk!

Setup

Install

First, you need to install bit-runner globally so that the bit-runner cli can be added to the PATH. This way you can call bitrunner from anywhere.

npm install bit-runner -g

Now that you have the cli in your PATH, you need to install bit-runner in your project. So from your project's root directory:

npm install bit-runner --save-dev

Configuration

When you execute bit runner's cli, it automatically loads bitrunnerfile.js from your project in order to load your tasks. Here is a basic configuration with a single task called build:

var bitRunner = require('bit-runner');

/**
 * JavaScript pipeline
 */
function buildPipeline(task) {
  task
    .load('index.js')
    .then(function action(moduleMeta) {
      moduleMeta.source = "'use strict;'\n" + moduleMeta.source;
    })
    .then(function action(moduleMeta) {
      moduleMeta.source = coffeescript.compile(moduleMeta.source);
    });
}

bitRunner.register('build', buildPipeline);

Running it

So, you have installed bit-runner and created a configuration in your project. Now you are ready to run your task(s). From your project's root directory:

bitrunner build

You can call bitrunner with a list of tasks, in which case bit runner is going to run them in parallel. Or if you don't provide a task name, then the default task is executed.

The following will execute build and docs in parallel.

bitrunner build docs

The following will execute default

bitrunner

Examples

Please see examples that illustrate different techniques for configuring bit runner.

bit-runner's People

Contributors

miguelcastillo avatar

Watchers

 avatar  avatar  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.