Skip to content

Instantly share code, notes, and snippets.

Last active Mar 12, 2020
What would you like to do?
import cleanStack from 'clean-stack';
// dims non-useful log lines in stack traces
const neatStack = (colorize, stack) => {
// add parts of stack trace lines here that should be ignored
const regexParts = [
'(at new Promise)',
const internalStackRegex = new RegExp(`at.*${regexParts}`);
const cleanedStack = cleanStack(String(stack));
const stackLines = cleanedStack.split('\n');
const title = R.head(stackLines);
const colorizedStackLines = R.pipe(
R.tail, =>
line.match(internalStackRegex) || line.match('From previous event')
? chalk.dim(line)
: colorize(line),
return colorize(`${title}\n${colorizedStackLines}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment