callumlocke / trip

Run JavaScript functions from the command line.
MIT License
1 stars 0 forks source link

trip.js NPM version Build Status Dependency Status

trip is a very simple task runner. You write functions in a tripfile and run them from the command line.


install

$ npm install --global trip

(You might also want to install a local copy with --save to lock down the version for your project.)


use

1. Create a tripfile.js and export some tasks

exports.greet = function () {
  console.log('hello world');
};

(You can also use tripfile.babel.js, tripfile.coffee, or whatever.)

2. run tasks from the command line

$ trip greet

async tasks

If you want to do something asynchronous in any task, just return a promise. Trip will wait till it resolves before the it deems the task complete.

running multiple tasks

Just run $ trip first second third to run as many tasks as you want in series.

subtasks

A task can be defined as an array of subtasks:

exports.build = ['first', 'second', 'third'];

Now you can do $ trip build to run those three tasks (in series).

You can also mix inline functions (as literals or references) directly into an array of subtasks:

exports.things = [
  'foo',

  function () {
    console.log('this runs between foo and bar');
  },

  'bar'
];

parallel subtasks

Use a nested array if you want to run certain subtasks in parallel:

exports.build = [ ['one', 'two'], 'three' ];

Now $ trip build will run tasks one and two in parallel, then it will finally run three.

Each level of nesting reverses the series:parallel decision, so you can do complex, over-engineered stuff if you want. Probably only useful in obscure cases.


licence

The MIT License