Gear Reference

Gear.js - Build System for Node.js and the Browser

Gear.js is a powerful build system with a clear and elegant syntax based on task chaining. Concatenate, lint and minify your stylesheets and javascripts, add version and licence information, fill in templates, all in a few lines of code.

Getting Started

Gear.js can be installed via npm, either locally or globally.

> npm install gear gear-lib or > npm install -g gear gear-lib

The Gearfile

The Gearfile is a valid javascript file containing the building instructions and placed at the root of your project.

In command line mode, just type :

> gear

and gear looks for a file named Gearfile or Gearfile.js in the current directory or the first up the directory tree and executes it.

Example : new gear.Queue({ registry: 'gear-lib' }) .read('src/myproject.js') .jsminify() .write('build/myproject.min.js') .log('Done !') .run();

Queues and Blobs

Gear uses Queues to manipulate Blobs :
Queue
A sequence of tasks defining and manipulating a list of Blobs.
Tasks in a Queue are executed in series, and multiple Queues in a Gearfile are executed in parallel.
The basic tasks are : reading and writing files, concatenation, string/regex replacement, appending and prepending data, writing messages to the console.
core tasks
gear-lib adds more complex tasks : jslint, jshint, uglify.js, less, csslint, handlebars, glob files, s3 deploy.
gear-lib tasks
Blob
Basically, a String with a name.
A Blob is an immutable data object loosely based on the W3C Blob, with a property bag as well as a result property.
Blobs can be merged with other blobs. When merging, properties in the property bag are merged, while result is concatenated.
The result property can be a Buffer or a String.

Utilities

Gear also provides some useful utility methods.

var package = gear.Util.readJSON('package.json');