Gear Reference

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

Along with Queues and Blobs, Gear.js provides some useful utility methods in the gear.Util object.



Reads a JSON file synchronously and returns the object.

// Automatically update bower.json with the version number taken from package.json var package = gear.Util.readJSON('package.json'); new gear.Queue() .read('bower.json') .replace({ regex: /"version": ".*",/, replace: '"version": "'+package.version+'",' }) .write('bower.json') .log('bower.json updated') .run();


Reads a JSON file with comments synchronously and returns the object. JSON files with comments are generally not considered valid. This method uses JSON.minify to remove all whitespaces and comments before parsing, allowing you to use human-friendly JSON config files.

/** * This file contains all configuration for the build process. * It's like a JSON file, but with a lot of comments. */ { // This will be displayed in the app's title bar. title: "My great app's title" } // Automatically set the title in index.html from the config file var config = gear.Util.readJSONC('build.config.json'); new gear.Queue() .read('index.tpl.html') .replace({ regex: '<title></title>', replace: '<title>' + config.title + '</title>' }) .write('index.html') .log('index.html created') .run();