UNPKG

1.34 kBJavaScriptView Raw
1// Generated by CoffeeScript 1.10.0
2(function() {
3 module.exports = function(opts) {
4 var autocode, i, runCmd, scripts, spawn;
5 autocode = this;
6 spawn = require('cross-spawn');
7 this.build(opts);
8 if (!this.config.scripts || !this.config.scripts.run) {
9 return "\n" + ' DONE! '.bgGreen.white;
10 }
11 console.log("\nRUN:".bold);
12 scripts = this.config.scripts;
13 i = 0;
14 runCmd = function() {
15 var arg, cmd, command, description, proc, run;
16 if (!scripts.run[i]) {
17 console.log("\n" + ' DONE! '.bgGreen.white);
18 return;
19 }
20 description = scripts.run[i].description || scripts.run[i];
21 command = scripts.run[i].command || scripts.run[i];
22 console.log(' RUN SCRIPT '.bgGreen.white + (' ' + description + ' ').bgWhite + " \n" + command.gray);
23 run = command;
24 run = [run.substr(0, run.indexOf(' ')), run.substr(run.indexOf(' ') + 1)];
25 cmd = run[0];
26 arg = run[1].split(' ');
27 proc = spawn(cmd, arg, {
28 stdio: 'inherit'
29 });
30 proc.on('close', function(err) {
31 return runCmd();
32 });
33 proc.on('error', function(err) {
34 return console.log("\n" + ' ERROR '.bgRed.white + (' ' + err.message + ' ').bgWhite);
35 });
36 return i++;
37 };
38 runCmd();
39 return 'Running...';
40 };
41
42}).call(this);