Created
May 12, 2022 14:38
-
-
Save nickreese/bde2322cd29aebd5e3619b0835bdb0b9 to your computer and use it in GitHub Desktop.
Clean Stacktraces In JS
This file contains hidden or 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
function cleanStack(stack) { | |
const parts = path.resolve('./').split('/'); | |
let str = stack.toString(); | |
for (const part of parts) { | |
const r = new RegExp(`/${part}/`, `gim`); | |
str = str.replace(r, '/'); | |
} | |
return str; | |
} | |
const e = new Error('test'); | |
const clean = cleanStack(e); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment