-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnpmnode.js
More file actions
68 lines (51 loc) · 1.81 KB
/
npmnode.js
File metadata and controls
68 lines (51 loc) · 1.81 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"use strict";
var util = require("util");
var c9util = require("../cloud9.core/util");
var ShellRunner = require("../cloud9.run.shell/shell").Runner;
var exports = module.exports = function setup(options, imports, register) {
var pm = imports["process-manager"];
imports.sandbox.getProjectDir(function(err, projectDir) {
if (err)
return register(err);
pm.addRunner("run-npm", exports.factory(imports.vfs, projectDir, options.nodePath));
register(null, {
"run-run-npm": {}
});
});
};
exports.factory = function(vfs, root, nodePath) {
return function(args, eventEmitter, eventName, callback) {
var options = {};
c9util.extend(options, args);
options.root = root;
options.file = args.file;
options.args = args.args;
options.env = args.env;
options.cwd = args.cwd;
options.extra = args.extra;
options.eventEmitter = eventEmitter;
options.eventName = eventName;
options.nodePath = nodePath;
new Runner(vfs, options, callback);
};
};
var Runner = exports.Runner = function(vfs, options, callback) {
var self = this;
this.uid = options.uid;
this.file = options.file;
this.extra = options.extra;
this.scriptArgs = options.args || [];
this.nodeArgs = [];
options.env = options.env || {};
options.command = options.nodePath || process.execPath;
options.nodePath = options.nodePath || process.execPath;
ShellRunner.call(self, vfs, options, callback);
};
util.inherits(Runner, ShellRunner);
(function() {
this.name = "run-npm";
this.createChild = function(callback) {
this.args = this.nodeArgs.concat(this.file, this.scriptArgs);
ShellRunner.prototype.createChild.call(this, callback);
};
}).call(Runner.prototype);