autocode-cli
Version:
code automation for every language, framework and platform
53 lines (49 loc) • 1.59 kB
JavaScript
// Generated by CoffeeScript 1.10.0
(function() {
var spawn;
spawn = require('cross-spawn');
module.exports = function() {
var i, scripts, stopCmd;
this.stopped = true;
if (!this.config.scripts || !this.config.scripts.stop) {
return 'No scripts for: stop';
}
console.log("\nSTOP:".bold);
scripts = this.config.scripts;
i = 0;
stopCmd = function() {
var arg, cmd, command, description, proc, stop;
if (!scripts.stop[i]) {
console.log("\nDone!");
process.kill(0);
return;
}
description = scripts.stop[i].description || scripts.stop[i];
command = scripts.stop[i].command || scripts.stop[i];
console.log(' STOP SCRIPT '.bgBlack.white + (' ' + description + ' ').bgWhite + " \n" + command.gray);
stop = command;
stop = [stop.substr(0, stop.indexOf(' ')), stop.substr(stop.indexOf(' ') + 1)];
cmd = stop[0];
arg = stop[1].split(' ');
proc = spawn(cmd, arg);
proc.stderr.on('data', function(data) {
return console.log(data.toString().red);
});
proc.stdout.on('error', function(data) {
return console.log(data.toString());
});
proc.stdout.on('data', function(data) {
return console.log(data.toString());
});
proc.on('close', function(err) {
return stopCmd();
});
proc.on('error', function(err) {
return console.log(' ERROR '.bgRed.white + (' ' + err.message + ' ').bgWhite);
});
return i++;
};
stopCmd();
return 'Stopping...';
};
}).call(this);