1 | var spawn = require('child_process').spawn;
|
2 | var exec = require('child_process').exec;
|
3 | var path = require('path');
|
4 | var fs = require('fs');
|
5 | var _ = require('underscore');
|
6 |
|
7 |
|
8 | Command = {
|
9 |
|
10 | spawn: function(meteorExec, args, package_dir, fn) {
|
11 | var options = {customFds: [0,1,2]};
|
12 | if (package_dir) {
|
13 | options.env = _.extend({PACKAGE_DIRS: package_dir}, process.env);
|
14 | }
|
15 |
|
16 | spawn(meteorExec, args, options)
|
17 | .on('error', function(err) {
|
18 |
|
19 | if (err.code === 'ENOENT') {
|
20 | if (meteorExec === 'meteor') {
|
21 | console.log("Can't find meteor executable!".red.bold);
|
22 | console.log();
|
23 | console.log("Please install meteor from http://meteor.com".red)
|
24 | } else {
|
25 |
|
26 | console.log(("Can't find executable at " + meteorExec).red.bold);
|
27 | console.log();
|
28 | console.log("Please run mrt uninstall --system, and try again.".red);
|
29 | }
|
30 | }
|
31 | })
|
32 | .on('exit', fn);
|
33 | },
|
34 |
|
35 |
|
36 | exec: function(meteorExec, args, fn) {
|
37 | args.unshift(meteorExec);
|
38 | var command = args.join(' ');
|
39 | exec(command, fn);
|
40 | }
|
41 | };
|
42 |
|
43 | module.exports = Command;
|