Skip to content

Commit

Permalink
lib/utils: Only replace absolute -> relative paths for stack lines
Browse files Browse the repository at this point in the history
the stack can include the error message which might contain paths that should not be replaced
  • Loading branch information
Turbo87 committed Mar 7, 2016
1 parent 83b72ed commit dc36508
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,11 @@ exports.stackTraceFilter = function() {
}

// Clean up cwd(absolute)
list.push(line.replace(cwd, ''));
if (/\(?.+:\d+:\d+\)?$/.test(line)) {
line = line.replace(cwd, '');
}

list.push(line);
return list;
}, []);

Expand Down
4 changes: 2 additions & 2 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ describe('utils', function() {
});

it('should replace absolute with relative paths', function() {
var stack = ['Error: failed'
var stack = ['Error: ' + process.cwd() + '/bla.js has a problem'
, 'at foo (' + process.cwd() + '/foo/index.js:13:226)'
, 'at bar (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/promise.js:11:26)'];

var expected = ['Error: failed'
var expected = ['Error: ' + process.cwd() + '/bla.js has a problem'
, 'at foo (foo/index.js:13:226)'
, 'at bar (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/promise.js:11:26)'];

Expand Down

0 comments on commit dc36508

Please sign in to comment.