[debugger] shorten break message

This commit is contained in:
Fedor Indutny
2011-09-21 17:59:04 +07:00
committed by Ryan Dahl
parent 79fd1f7f0b
commit 8efe7a8304

View File

@@ -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)
);
}
}