Skip to content

Commit

Permalink
consolidate utils.trace
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Jun 29, 2017
1 parent 654a136 commit 271fb7d
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions packages/taskr/lib/utils/trace.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
"use strict"
'use strict';

const extractPath = /\s+at.*(?:\(|\s)(.*)\)?/
const isPath = /^(?:(?:(?:node|(?:internal\/[\w/]*)?\w+)\.js:\d+:\d+)|native)/
const extractPath = /\s+at.*(?:\(|\s)(.*)\)?/;
const isPath = /^(?:(?:(?:node|(?:internal\/[\w/]*)?\w+)\.js:\d+:\d+)|native)/;

module.exports = function (stack) {
return stack.replace(/\\/g, "/")
.split("\n")
.filter(x => {
const pathMatches = x.match(extractPath)

if (pathMatches === null || !pathMatches[1]) {
return true;
}

return !isPath.test(pathMatches[1])
})
.filter(x => x.trim() !== "")
.join("\n")
return stack.replace(/\\/g, '/').split('\n').filter(x => {
const matches = x.match(extractPath);
return matches === null || !matches[1] || !isPath.test(matches[1]);
}).filter(x => x.trim() !== '').join('\n');
}

0 comments on commit 271fb7d

Please sign in to comment.