UNPKG

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