Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
clean-stack
Advanced tools
The clean-stack npm package is designed to clean up error stack traces. It removes the noise from stack traces, making them easier to read and understand. This is particularly useful in development and production environments where error logs can become cluttered with irrelevant paths and lines. By simplifying stack traces, developers can more quickly identify the source of errors.
Cleaning stack traces
This feature allows you to clean up the stack trace of an error. The `cleanStack` function takes an error stack as input and returns a cleaner, more readable version of it. This is particularly useful for logging and error handling in applications.
const cleanStack = require('clean-stack');
const error = new Error('An error occurred!');
console.log(cleanStack(error.stack));
The 'stack-trace' package provides utilities for working with stack traces. It allows you to parse and inspect stack traces. Compared to 'clean-stack', 'stack-trace' offers more detailed manipulation and inspection capabilities but does not focus specifically on cleaning or simplifying the stack traces.
This package is used to parse JavaScript Error stack strings and extract stack frames from them. While 'error-stack-parser' focuses on parsing and extracting information from stack traces, 'clean-stack' is more about cleaning and simplifying them for better readability.
Clean up error stack traces
Removes the mostly unhelpful internal Node.js entries.
Also works in Electron.
$ npm install clean-stack
const cleanStack = require('clean-stack');
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)
*/
console.log(cleanStack(error.stack));
/*
Error: Missing unicorn
at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15)
*/
Type: string
The stack
property of an Error
.
Type: object
Type: boolean
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
Type: string?
Remove the given base path from stack trace file paths, effectively turning absolute paths into relative ones.
Example with '/Users/sindresorhus/dev/clean-stack/'
as basePath
:
/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15
→ unicorn.js:2:15
FAQs
Clean up error stack traces
We found that clean-stack demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.