Permalink
Browse files

[debugger] shorten break message

  • Loading branch information...
1 parent c55386f commit b8475bd97af691c78ecfb8b7fcc79d08dddaf9bc @indutny committed Sep 21, 2011
Showing with 15 additions and 16 deletions.
  1. +15 −16 lib/_debugger.js
View
@@ -19,10 +19,11 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
-var net = require('net'),
- repl = require('repl'),
+var util = require('util'),
+ path = require('path'),
+ net = require('net'),
vm = require('vm'),
- util = require('util'),
+ repl = require('repl'),
inherits = util.inherits,
spawn = require('child_process').spawn;
@@ -671,24 +672,22 @@ function SourceUnderline(sourceText, position) {
}
-function SourceInvocation(body) {
- return body.invocationText.replace(/\n/g, '')
- .replace(/^([^(]*)\(.*\)([^)]*)$/, '$1(...)$2');
-}
-
-
function SourceInfo(body) {
- var result = 'break in ' + SourceInvocation(body);
+ var result = 'break in ';
if (body.script) {
if (body.script.name) {
- var name = body.script.name;
+ var name = body.script.name,
+ dir = path.resolve() + '/';
- // TODO Change path to relative, if possible
+ // Change path to relative, if possible
+ if (name.indexOf(dir) === 0) {
+ name = name.slice(dir.length);
+ }
- result += ', ' + name;
+ result += name;
} else {
- result += ', [unnamed]';
+ result += '[unnamed]';
}
}
result += ':';
@@ -1096,7 +1095,7 @@ Interface.prototype.backtrace = function() {
if (frame.func.inferredName && frame.func.inferredName.length > 0) {
text += frame.func.inferredName + ' ';
}
- text += require('path').basename(frame.script.name) + ':';
+ text += path.basename(frame.script.name) + ':';
text += (frame.line + 1) + ':' + (frame.column + 1);
trace.push(text);
@@ -1128,7 +1127,7 @@ Interface.prototype.scripts = function() {
scripts.push(
(script.name == client.currentScript ? '* ' : ' ') +
id + ': ' +
- require('path').basename(script.name)
+ path.basename(script.name)
);
}
}

0 comments on commit b8475bd

Please sign in to comment.