-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathcommand.js
More file actions
43 lines (39 loc) · 1.34 KB
/
command.js
File metadata and controls
43 lines (39 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var spawn = require('spawn-cmd').spawn;
var exec = require('child_process').exec;
var path = require('path');
var fs = require('fs');
var _ = require('underscore');
// Just some utilities to `run` meteor commands
Command = {
// execute a command and print it's output to the screen
spawn: function(meteorExec, args, package_dir, fn) {
var options = {customFds: [0,1,2]};
if (package_dir) {
options.env = _.extend({PACKAGE_DIRS: package_dir}, process.env);
}
spawn(meteorExec, args, options)
.on('error', function(err) {
// yikes! can't find the executable!
if (err.code === 'ENOENT') {
if (meteorExec === 'meteor') {
console.log("Can't find meteor executable!".red.bold);
console.log();
console.log("Please install meteor from http://meteor.com".red)
} else {
// XXX: is this possible?
console.log(("Can't find executable at " + meteorExec).red.bold);
console.log();
console.log("Please run mrt uninstall --system, and try again.".red);
}
}
})
.on('exit', fn);
},
// execute a command and return it's output to fn
exec: function(meteorExec, args, fn) {
args.unshift(meteorExec);
var command = args.join(' ');
exec(command, fn);
}
};
module.exports = Command;