Gear Reference

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

The core set of tasks can be extended with the help of a task registry. The Gear-lib registry provides a set of advanced Queue tasks based on commonly used external dependencies.

Queue initialization

new gear.Queue({ registry: 'gear-lib' }) ... // Chain some task declarations .run(); // Starts the execution of the tasks

Gear-lib tasks


Lints your CSS code with CSS Lint. All blobs are linted.
options is an object with the following properties :
Optional configuration object for CSS Lint. List of rules to apply. By default, all rules are used. If a rule has a value of 1 then it's a warning, a value of 2 means it's an error.
Example : { "adjoining-classes": 1, "box-model": 1 }
See CSSLint rules.
Don't forget to give this callback, or your CSSLint error report will be discarded.
If CSSLint doesn't find any errors in your CSS, an empty object {} will be passed to this function.
If there are errors, the argument object will contain them as an array in the csslint property of the argument.
The return value determines if the Queue aborts or continues.
new gear.Queue({ registry: 'gear-lib' }) .read('styles.css') .csslint({ callback: function(linted) { if (linted.csslint) { // linted.csslint is the list of error descriptions. console.log(linted.csslint); // Return truthy value to abort the Queue. return 'CSS has ' + linted.csslint.length + ' errors'; } // No errors }) .run();


Alias of the less() task.


Reads multiple files using name patterns like stars and stuff. See node-glob.
config is an object with the following properties :
A string describing the file names to match :
  • ? matches any single character except a /.
  • * matches 0 or more of any character except a /.
  • ** matches any subfolder, if it is the only thing in a path part.
  • Character classes : [A-Fa-f0-9] matches any single character from A to F or from a to f or from 0 to 9
A map of options passed to Glob.
Defaults to 'utf-8'.
new gear.Queue({ registry: 'gear-lib' }) .glob({ pattern: '**/*.js' }) // reads recursively all javascript files .run();


Uses the handlebars template engine to fill your templates with computed values.
Each Blob in the list is considered a template to fill.
variables is an object used to fill the templates.

new gear.Queue({ registry: 'gear-lib' }) .append('Current date is {{ date }}, version number is {{ version }}') .handlebars({ date: new Date().toISOString(), version: '1.3.2' }) .inspect() // prints "Current date is 2014-05-19T18:44:11.891Z, version number is 1.3.2" .run();


Checks your javascript files with JSHint. If errors are found, they are displayed on the console and the Queue stops.
options is an optional object with the following properties :

path to a JSHint configuration file, such as .jshintrc
A custom JSHint configuration object. See the JSHint doc, and all JSHint options.
A function to be called with the linting error object. Can return non-null to end the Queue.
new gear.Queue({ registry: 'gear-lib' }) .read('src/app.js') .jshint() // default behavior .jshint({ configfile: '.jshintrc' }) // with the project's config .jshint({ config: { eqeqeq: true } }) // with some custom config .run();


Checks your javascript files with JSLint. Errors are passed to a callback. config is a mandatory object with the following properties :

An optional custom JSLint configuration object. See the JSLint doc.
A function to be called with the linting error object. Can return non-null to end the Queue. If this callback is not given, all linting messages will be silently ignored.
new gear.Queue({ registry: 'gear-lib' }) .read('src/app.js') .jslint({ config: { bitwise: true }, callback: function(err) { if(err.jslint) { console.log('The following errors were detected by jslint:'); return err.jslint; // returning non-null stops the Queue and displays the error object. } } }) .run();


Uses UglifyJS to compress/minify/mangle your JS code. All Blobs in the list are minified.
options is an object with the following properties :

An optional custom configuration object. See the UglifyJS doc. By default, comments containing licence information are preserved. To remove all comments, set config.output.comments to false.
If an error occurs during minification, this optional function is called with the error object.
new gear.Queue({ registry: 'gear-lib' }) .read('src/app.js') .jsminify({ config: { mangle: false, output: { ascii_only: true, comments: false }, compress: { unsafe: true, global_defs: { DEBUG: false } } } }) .run();


Compiles and minifies Less style sheets. All blobs are compiled.
options is an optional configuration object. Example { compress: false }
If an error is found, the Queue stops and the error is displayed.


Deploy files to Amazon S3. config is an object with the following properties :

Name of the file to upload to S3
S3 API key
S3 secret key
S3 bucket
new gear.Queue({ registry: 'gear-lib' }) .read('src/app.js') .jsminify() .s3({ name: 'app.min.js', client: { key: '<my API key>', secret: '<my secret key>', bucket: 'my-bucket' } }) .run();