forked from Vhornets/brackets-builder
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdomain.js
50 lines (43 loc) · 1.41 KB
/
domain.js
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
44
45
46
47
48
49
50
/*global require, exports */
(function () {
"use strict";
var child_process = require("child_process"),
domainName = "builder.execute";
function exec(directory, command, callback) {
//directory = directory.replace(" ", "\\ ");
console.log("exec "+command+" from "+directory);
//directory = '"'+directory+'"';
child_process.exec(command, { cwd: directory}, function (err, stdout, stderr) {
//console.log("returned: " + stdout);
//console.log("err: " + err);
if(err && !stderr) { stderr = stdout; }
//callback(err, stdout);
callback(err ? stderr : undefined, err ? undefined : stdout);
});
}
exports.exec = exec;
exports.init = function (DomainManager) {
if (!DomainManager.hasDomain(domainName)) {
DomainManager.registerDomain(domainName, {
major: 0,
minor: 1
});
}
DomainManager.registerCommand(domainName, "exec", exec, true, "Exec cmd",
[
{
name: "directory",
type: "string"
},
{
name: "command",
type: "string"
}
],
[{
name: "stdout",
type: "string"
}]
);
};
}());