-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
80 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module.exports = { | ||
/** | ||
* Clean up Node.js stack trace | ||
* @param {string} stack | ||
* @return {string} | ||
*/ | ||
clean: (stack) => { | ||
const extractPathRegex = /\s+at.*[(\s](.*)\)?/ | ||
const pathRegex = /^(?:(?:(?:node|node:[\w/]+|(?:(?:node:)?internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)(?:\.js)?:\d+:\d+)|native)/ | ||
|
||
if (typeof stack !== "string") { | ||
return undefined | ||
} | ||
|
||
return stack | ||
.replace(/\\/g, "/") | ||
.split("\n") | ||
.filter((line) => { | ||
const pathMatches = line.match(extractPathRegex) | ||
if (pathMatches === null || !pathMatches[1]) { | ||
return true | ||
} | ||
|
||
const match = pathMatches[1] | ||
|
||
// Electron (windows) | ||
if (match.includes("node_modules/electron/dist/resources/electron.asar") || match.includes("node_modules/electron/dist/resources/default_app.asar")) { | ||
return false | ||
} | ||
|
||
return !pathRegex.test(match) | ||
}) | ||
.filter((line) => line.trim() !== "") | ||
.map((line) => { | ||
return line | ||
}) | ||
.join("\n") | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters