diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2010-12-23 04:17:34 +0300 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-12-30 12:35:12 +0300 |
commit | 0dcbe3f74a0d92a399c508c92110648e76917d9b (patch) | |
tree | 3c347b311ec7e0783d046feb4e876af5184b8df3 /lib | |
parent | 4e81cf7def7c672b620086323c34010d2718e697 (diff) |
Fork out to debugger on debugger statements
Also implement continue in Client.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/_debugger.js | 36 | ||||
-rw-r--r-- | lib/readline.js | 2 |
2 files changed, 34 insertions, 4 deletions
diff --git a/lib/_debugger.js b/lib/_debugger.js index 25f82e72e1f..83bc6c8fba0 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -212,6 +212,13 @@ Client.prototype.reqScripts = function(cb) { }; +Client.prototype.reqContinue = function(cb) { + this.req({ command: 'continue' } , function (res) { + if (cb) cb(res.body); + }); +}; + + var helpMessage = "Commands: scripts, backtrace, version, eval, help, quit"; @@ -223,18 +230,33 @@ function startInterface() { i.write(chunk); }); - var prompt = '> '; + var prompt = 'debug> '; i.setPrompt(prompt); i.prompt(); - i.on('SIGINT', function() { + var quitTried = false; + + function tryQuit() { + if (quitTried) return; + quitTried = true; i.close(); - }); + console.log("debug done\n"); + if (c.writable) { + c.reqContinue(function (res) { + process.exit(0); + }); + } else { + process.exit(0); + } + } + + i.on('SIGINT', tryQuit); + i.on('close', tryQuit); i.on('line', function(cmd) { if (cmd == 'quit') { - process.exit(0); + tryQuit(); } else if (/^help/.test(cmd)) { console.log(helpMessage); i.prompt(); @@ -251,6 +273,12 @@ function startInterface() { i.prompt(); }); + } else if ('continue' == cmd || 'c' == cmd) { + c.reqContinue(function (res) { + console.log(res); + i.prompt(); + }); + } else if (/^scripts/.test(cmd)) { c.reqScripts(function (res) { var text = res.map(function (x) { return x.text; }); diff --git a/lib/readline.js b/lib/readline.js index 341b20b4795..3ae43f4735a 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -160,6 +160,8 @@ Interface.prototype._refreshLine = function() { Interface.prototype.close = function(d) { + if (this._closing) return; + this._closing = true; if (this.enabled) { tty.setRawMode(false); } |