Meant to be used with clean-stacktrace as mapper function. Makes absolute paths inside stack traces to relative paths.
You might also be interested in always-done.
(TOC generated by verb using markdown-toc)
Install with npm
$ npm install clean-stacktrace-relative-paths --save
or install using yarn
$ yarn add clean-stacktrace-relative-paths
For more use-cases see the tests
const cleanStacktraceRelativePaths = require('clean-stacktrace-relative-paths')
Cleans stack traces to use relative paths, instead of absolute paths. Pass a
cwd
if you want to customize, otherwiseprocess.cwd()
is used by default.
Meant to be used as mapper
argument in clean-stacktrace
Params
[cwd]
{String}: custom current working directoryreturns
{Function}: a function that can be passed asmapper
to clean-stacktrace
Example
const cleanStack = require('clean-stacktrace')
const relativePaths = require('clean-stacktrace-relative-paths')
const error = new Error('Missing unicorn')
console.log(error.stack)
// =>
// Error: Missing unicorn
// at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15)
// at Module._compile (module.js:409:26)
// at Object.Module._extensions..js (module.js:416:10)
// at Module.load (module.js:343:32)
// at Function.Module._load (module.js:300:12)
// at Function.Module.runMain (module.js:441:10)
// at startup (node.js:139:18)
const mapper = relativePaths()
const stack =