Skip to content

Commit

Permalink
wip proxy commands to meteor cli
Browse files Browse the repository at this point in the history
- problem killing child process on sigint
- also sometimes parent process quits without waiting for child process
- need to do more research
  • Loading branch information
cmather committed Feb 12, 2015
1 parent b722725 commit 6286599
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions lib/em.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var Command = require('./command.js');
var Table = require('cli-table');
var cli = require('cli-color');
var Config = require('./config.js');
var spawn = require('child_process').spawn;

var requireAll = function (relpath) {
var dirpath = path.join(__dirname, relpath);
Expand Down Expand Up @@ -42,10 +43,32 @@ em = new Command({

}
}, function (args, opts) {
var command = args[0];
if (!command)
throw new Command.UsageError;
this.runSubCommand(command, args.slice(1), opts);
var command = args[0] || 'run';

try {
this.runSubCommand(command, args.slice(1), opts);
} catch (e) {
if (e instanceof Command.UsageError) {
var appDir;
if (appDir = this.findAppDirectory()) {
var meteorArgs = process.argv.slice(3);

//XXX how to properly kill the child process on sigint?
//XXX why does the parent process exit, and then sometimes
//resume later?
var childProcess = spawn('meteor', meteorArgs, {
cwd: appDir,
env: process.env,
stdio: 'inherit',
killSignal: 'SIGTERM'
});
} else {
throw e;
}
} else {
throw e;
}
}
});

em.Command = Command;
Expand Down

0 comments on commit 6286599

Please sign in to comment.