File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ R = require 'ramda'
22psTree = require ' ps-tree'
33Promise = require ' bluebird'
44{Client } = require ' _debugger'
5- { spawn } = require ' child_process'
5+ childprocess = require ' child_process'
66{EventEmitter } = require ' events'
77Event = require ' geval/event'
88logger = require ' ./logger'
@@ -40,7 +40,7 @@ class ProcessManager extends EventEmitter
4040 appArgs or ' '
4141 ]
4242
43- @process = spawn nodePath, args, {
43+ @process = childprocess . spawn nodePath, args, {
4444 detached : true
4545 }
4646
Original file line number Diff line number Diff line change 1+ childprocess = require ' child_process'
2+ {EventEmitter } = require ' events'
3+ {ProcessManager } = require ' ../../lib/debugger'
4+ Stream = require ' stream'
5+
6+ makeFakeProcess = () ->
7+ process = new EventEmitter ()
8+ process .stdout = new Stream ()
9+ process .stderr = new Stream ()
10+
11+ return process
12+
13+ describe ' ProcessManager' , ->
14+ describe ' .start' , ->
15+ it ' starts a process base on the atom config and if no file specify' , ->
16+
17+ mapping = {
18+ ' atom-node-debugger.nodePath' : ' /bin/node'
19+ ' atom-node-debugger.appArgs' : ' --name'
20+ ' atom-node-debugger.debugPort' : 5858
21+ }
22+
23+ atomStub =
24+ workspace :
25+ getActiveTextEditor : ->
26+ getPath : -> ' /path/to/file.js'
27+ config :
28+ get : (key ) -> mapping[key]
29+
30+ spyOn (childprocess, ' spawn' ).andReturn (makeFakeProcess ())
31+
32+ manager = new ProcessManager (atomStub)
33+ waitsForPromise () ->
34+ manager .start ().then () ->
35+ expect (childprocess .spawn ).toHaveBeenCalled ()
36+ expect (childprocess .spawn ).toHaveBeenCalledWith (' /bin/node' )
You can’t perform that action at this time.
0 commit comments