sindresorhus / clean-stack

Clean up error stack traces
MIT License
337 stars 29 forks source link

Add option to keep blank lines #5

Closed SimenB closed 6 years ago

SimenB commented 7 years ago

When the stacktrace is part of a larger string (for instance captured console.logs with traces) it's sometimes useful to keep around empty lines.

sindresorhus commented 7 years ago

Do you have a more specific use-case? I'm failing to see the usefulness of this.

SimenB commented 6 years ago

@sindresorhus sorry about the slow response!

My use case is that the stacktrace itself is already part of a larger string, which has some blank lines for readability. If I pass that string though clean-stack to remove node internals, it also strips the lines I want it to keep.

Example is an assertion failure

   Expected value to be (operator: ==):
      true
    Received:
      false

      at __tests__/node_assertion_error.test.js:23:10
          at <anonymous>
      at internal/process/next_tick.js:188:7

I want clean-stack to remove e.g. internal/process/next_tick.js:188:7, but I don't want it to remove the blank line between the start of the stack trace, and the false part of the string

SimenB commented 6 years ago

I pushed an updated test to better illustrate my use case. Doesn't show up here since the PR is closed.

https://github.com/SimenB/clean-stack/commit/4079afda5a2dec5ad0794049fa0d821f1e26cf18