UNPKG

autocode

Version:

the ultimate developer platform

43 lines (41 loc) 1.34 kB
// Generated by CoffeeScript 1.10.0 (function() { module.exports = function(opts) { var autocode, i, runCmd, scripts, spawn; autocode = this; spawn = require('cross-spawn'); this.build(opts); if (!this.config.scripts || !this.config.scripts.run) { return "\n" + ' DONE! '.bgGreen.white; } console.log("\nRUN:".bold); scripts = this.config.scripts; i = 0; runCmd = function() { var arg, cmd, command, description, proc, run; if (!scripts.run[i]) { console.log("\n" + ' DONE! '.bgGreen.white); return; } description = scripts.run[i].description || scripts.run[i]; command = scripts.run[i].command || scripts.run[i]; console.log(' RUN SCRIPT '.bgGreen.white + (' ' + description + ' ').bgWhite + " \n" + command.gray); run = command; run = [run.substr(0, run.indexOf(' ')), run.substr(run.indexOf(' ') + 1)]; cmd = run[0]; arg = run[1].split(' '); proc = spawn(cmd, arg, { stdio: 'inherit' }); proc.on('close', function(err) { return runCmd(); }); proc.on('error', function(err) { return console.log("\n" + ' ERROR '.bgRed.white + (' ' + err.message + ' ').bgWhite); }); return i++; }; runCmd(); return 'Running...'; }; }).call(this);