Socket
Socket
Sign inDemoInstall

clean-stack

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clean-stack - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

13

index.js
'use strict';
const os = require('os');
const extractPathRegex = /\s+at.*(?:\(|\s)(.*)\)?/;
const pathRegex = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/babel-polyfill\/.*)?\w+)\.js:\d+:\d+)|native)/;
const homeDir = os.homedir();
module.exports = stack => {
module.exports = (stack, options) => {
options = Object.assign({pretty: false}, options);
return stack.replace(/\\/g, '/')

@@ -26,3 +30,10 @@ .split('\n')

.filter(x => x.trim() !== '')
.map(x => {
if (options.pretty) {
return x.replace(extractPathRegex, (m, p1) => m.replace(p1, p1.replace(homeDir, '~')));
}
return x;
})
.join('\n');
};

2

package.json
{
"name": "clean-stack",
"version": "1.2.0",
"version": "1.3.0",
"description": "Clean up error stack traces",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -43,2 +43,26 @@ # clean-stack [![Build Status](https://travis-ci.org/sindresorhus/clean-stack.svg?branch=master)](https://travis-ci.org/sindresorhus/clean-stack)

## API
### cleanStack(stack, [options])
#### stack
Type: `string`
The `stack` property of an `Error`.
#### options
Type: `Object`
##### pretty
Type: `boolean`<br>
Default: `false`
Prettify the file paths in the stack:
`/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15` → `~/dev/clean-stack/unicorn.js:2:15`
## Related

@@ -45,0 +69,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc