UNPKG

1.35 kBJavaScriptView Raw
1// Generated by CoffeeScript 1.6.3
2var colors, normalize, spawn;
3
4normalize = require('path').normalize;
5
6spawn = require('child_process').spawn;
7
8colors = require('colors');
9
10module.exports.inspector = function(opts, kids, refresh) {
11 var arg1, arg2, arg3, bin, debugPort, kid1, kid2, script, webPort, _ref;
12 _ref = opts.args, arg1 = _ref[0], arg2 = _ref[1], arg3 = _ref[2];
13 if (arg3 != null) {
14 webPort = arg1;
15 debugPort = arg2;
16 script = arg3;
17 } else if (arg2 != null) {
18 webPort = arg1;
19 debugPort = 5858;
20 script = arg2;
21 } else {
22 webPort = 8080;
23 debugPort = 5858;
24 script = arg1;
25 }
26 bin = normalize(__dirname + '/../node_modules/.bin/node-inspector');
27 kids.push(kid1 = spawn(bin, ["--web-port=" + (webPort || 8080)]));
28 kid1.stderr.on('data', function(chunk) {
29 return refresh(chunk.toString(), 'stderr');
30 });
31 kid1.stdout.on('data', function(chunk) {
32 var str;
33 str = chunk.toString();
34 str = str.replace(/5858/, debugPort);
35 return refresh(str);
36 });
37 bin = normalize(__dirname + '/../node_modules/.bin/node-dev');
38 kids.push(kid2 = spawn(bin, ["--debug=" + debugPort, script]));
39 kid2.stderr.on('data', function(chunk) {
40 return refresh(chunk.toString(), 'stderr');
41 });
42 return kid2.stdout.on('data', function(chunk) {
43 return refresh(chunk.toString());
44 });
45};