forked from kiddkai/atom-node-debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode-debugger.coffee
More file actions
95 lines (83 loc) · 2.54 KB
/
Copy pathnode-debugger.coffee
File metadata and controls
95 lines (83 loc) · 2.54 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
NodeDebuggerView = require './node-debugger-view'
{CompositeDisposable} = require 'atom'
{Debugger, ProcessManager} = require './debugger'
jumpToBreakpoint = require './jump-to-breakpoint'
logger = require './logger'
os = require 'os'
processManager = null
_debugger = null
onBreak = null
module.exports =
nodeDebuggerView: null
config:
nodePath:
type: 'string'
default: if os.platform() is 'win32' then 'node.exe' else '/bin/node'
debugPort:
type: 'number'
minium: 5857
maxium: 65535
default: 5858
debugHost:
type: 'string'
default: '127.0.0.1'
nodeArgs:
type: 'string'
default: ''
appArgs:
type: 'string'
default: ''
isCoffeeScript:
type: 'boolean'
default: false
env:
type: 'string'
default: ''
activate: () ->
@disposables = new CompositeDisposable()
processManager = new ProcessManager(atom)
_debugger = new Debugger(atom, processManager)
@disposables.add _debugger.subscribeDisposable 'connected', ->
atom.notifications.addSuccess('connected, enjoy debugging : )')
@disposables.add _debugger.subscribeDisposable 'disconnected', ->
atom.notifications.addInfo('finish debugging : )')
@disposables.add atom.commands.add('atom-workspace', {
'node-debugger:start-resume': @startOrResume
'node-debugger:stop': @stop
'node-debugger:toggle-breakpoint': @toggleBreakpoint
'node-debugger:step-next': @stepNext
'node-debugger:step-in': @stepIn
'node-debugger:step-out': @stepOut
})
jumpToBreakpoint(_debugger)
startOrResume: =>
if _debugger.isConnected()
_debugger.reqContinue()
else
processManager.start()
NodeDebuggerView.show(_debugger)
toggleBreakpoint: =>
editor = atom.workspace.getActiveTextEditor()
path = editor.getPath()
{row} = editor.getCursorBufferPosition()
_debugger.breakpointManager.toggleBreakpoint editor, path, row
stepNext: =>
_debugger.step('next', 1) if _debugger.isConnected()
stepIn: =>
_debugger.step('in', 1) if _debugger.isConnected()
stepOut: =>
_debugger.step('out', 1) if _debugger.isConnected()
stop: =>
processManager.cleanup()
_debugger.cleanup()
NodeDebuggerView.destroy()
jumpToBreakpoint.cleanup()
deactivate: ->
logger.info 'deactive', 'stop running plugin'
jumpToBreakpoint.destroy()
@stop()
@disposables.dispose()
NodeDebuggerView.destroy()
_debugger.dispose()
serialize: ->
nodeDebuggerViewState: @nodeDebuggerView.serialize()