Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 36aa1eec4d
Fetching contributors…

Cannot retrieve contributors at this time

executable file 76 lines (67 sloc) 2.108 kb
#! /usr/bin/env node
//
// NodeApplicationManager $OPTIONS < $CMD[] | NodeApplicationManager $OPTIONS $CMD
// $OPTIONS
// --cwd|-C path
// --integrate|-i [security|npm|...]
// --config|-c [*.json] # must be a file ending in .json
// $CMD
// task[checkout|npm|grunt|run] $ARGS
//
// run NodeApplicationManager in the rootdir you want
//
var async = require('async');
var path = require('path');
var NodeApplicationManager = require('../').NodeApplicationManager;
var scaffold = new NodeApplicationManager();
scaffold.config = require('nconf').argv().env();
scaffold.config.file(scaffold.config.get('config') || scaffold.config.get('c') || 'config.json');
var chdir = scaffold.config.get('cwd') || scaffold.config.get('C');
if (scaffold.config.get('cwd')) {
process.chdir(scaffold.config.get('cwd'));
}
var integrations = [].concat(scaffold.config.get('integrate'), scaffold.config.get('i')).filter(Boolean);
if (integrations) {
var integrationsdir = path.join(__dirname, '..', 'integrations');
integrations.forEach(function (integration) {
scaffold.integrate(require(path.resolve(integrationsdir, integration)));
});
}
function done(err) {
if (err) {
console.error(err.stack || err);
process.exit(err.code || 1);
}
}
var args = scaffold.config.get('_').map(String);
if (!args.length) {
if (!process.stdin.isTTY) {
var buffs = [];
process.stdin.on('end', function () {
var tasks = JSON.parse(buffs.join(''));
runTasks(tasks);
});
process.stdin.on('data', buffs.push.bind(buffs));
process.stdin.resume();
}
else {
process.exit(0);
}
}
else {
if (!process.stdin.isTTY) {
console.error('Cannot accept both CLI task and stdin tasks');
process.exit(1);
}
runTasks([
[args.shift(), args, null]
]);
}
function runTasks(tasks) {
async.forEachSeries(tasks, function (taskDefinition, next) {
var cmd = taskDefinition[0];
var args = taskDefinition[1] || [];
var options = taskDefinition[2] || null;
scaffold.task(cmd, args, null, next);
}, done);
}
Jump to Line
Something went wrong with that request. Please try again.