building v0.3.0
Building 
Whatever good things we build end up building us. (Jim Rohn)
Building helps you write custom tasks for your favorite build tool.
Installation
npm install building --save-devUsage
// require the whole module...
var building = require('building');
// or specific parts
var files = require('building').files;
return files.writeJson('/tmp/file.json', {hello:'world'});Promise friendly
All methods tend to manipulate I/O and thus are asynchronous. They use exclusively promises.
building module
The building module exposes the following helpers:
- files
- shell
building.files
var files = require('building').files;glob(pattern, options)
- return:
{Promise}
Promisification of glob method from glob module. The documentation is available on glob repository.
copyFiles(filePaths, destinationDirectory, options)
filePaths{Array<String>}The file paths to copydestinationDirectory{String}The destination directoryoptions{Object}- return:
{Promise}
Copy given files at the root of the destination directory.
Options
preservePathAfter{String}Copy files but preserve the path after the given one. Example: when copyingsrc/assets/js/file.jsintodist, you may want to preserve the path aftersrc/assetsto obtaindist/js/file.js.
globAndCopyFiles(globbing, destinationDirectory, options)
globbing{Object}The globbing informationdestinationDirectory{String}The destination directoryoptions{Object}- return:
{Promise}
Glob files then copy them like copyFiles.
Globbing
The globbing object contains:
patternoptions
They correspond to the arguments of the glob method.
Options
Same options as building.files.copyFiles.
writeContent(destination, content)
destination{String}The destination file, existing or notcontent{String}The content to write- return:
{Promise}
Write content to an existing file or create it before.
writeJson(destination, object)
destination{String}The destination file, existing or notobject{Object}The object to write as JSON- return:
{Promise}
Write object as JSON to an existing file or create it before.
building.shell
var shell = require('building').shell;execute(binary, args, options)
binary{String}The binary to executeargs{Array<String>}The arguments to passoptions{Object}- return:
{Promise}
Execute a binary with its arguments.
Options
resolveLocalBin{Boolean}(default:false) Set totrueto resolve binary from localnode_modulesbinary. Example ifbinaryisjshintandresolveLocalBinistrue, the resolved binary is./node_modules/.bin/jshint.
executeLocal(binary, args, options)
Shortcut to execute with resolveLocalBin option set to true.
createExecution(binary, args, options)
binary{String}The binary to executeargs{Array<String>}The arguments to passoptions{Object}- return:
{Object}containing:- value
{ChildProcess}The standard Node.JS child process - promise
{Promise}The execution promise
- value
Like building.shell.execute but returns an execution object to access the child process.
Options
Same options as building.shell.execute.