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

.csslint(options)

Lints your CSS code with CSS Lint. All blobs are linted.
options is an object with the following properties :
config
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.
callback
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();

.cssminify([options])

Alias of the less() task.

.glob(config)

Reads multiple files using name patterns like stars and stuff. See node-glob.
config is an object with the following properties :
pattern
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
options
A map of options passed to Glob.
encoding
Defaults to 'utf-8'.
new gear.Queue({ registry: 'gear-lib' }) .glob({ pattern: '**/*.js' }) // reads recursively all javascript files .run();

.handlebars(variables)

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();

.jshint([options])

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 :

configFile
path to a JSHint configuration file, such as .jshintrc
config
A custom JSHint configuration object. See the JSHint doc, and all JSHint options.
callback
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();

.jslint(config)

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

config
An optional custom JSLint configuration object. See the JSLint doc.
callback
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();

.jsminify([options])

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

config
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.
callback
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();

.less([options])

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.

.s3(config)

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

name
Name of the file to upload to S3
client.key
S3 API key
client.secret
S3 secret key
client.bucket
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();