Skip to content
This repository was archived by the owner on Aug 19, 2019. It is now read-only.

Commit 3db5cab

Browse files
author
deepsweet
committed
➕ clean stack traces
1 parent 6f950f0 commit 3db5cab

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Pretty logger for [Start](https://github.com/start-runner/start).
77
* colors
88
* decamelized task names
99
* short relative paths
10+
* clean stack traces
1011

1112
![screenshot](screenshot.png)
1213

lib/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from 'path';
22
import decamelize from 'decamelize';
33
import chalk from 'chalk';
4+
import StackUtils from 'stack-utils';
45

56
export default (options = { mute: [] }) => (rawName, type, message) => {
67
const name = '→ ' + decamelize(rawName, ' ');
@@ -22,7 +23,14 @@ export default (options = { mute: [] }) => (rawName, type, message) => {
2223
if (type === 'reject') {
2324
// hard error
2425
if (message instanceof Error) {
25-
console.error(chalk.red(message.stack));
26+
const stackUtils = new StackUtils({
27+
cwd: process.cwd(),
28+
internals: StackUtils.nodeInternals()
29+
});
30+
const stack = stackUtils.clean(message.stack).trim();
31+
32+
console.log(`${chalk.red(name)}: ${message.message}`);
33+
console.error(chalk.red(stack));
2634
// soft error(s)
2735
} else {
2836
[].concat(message).forEach(msg => {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
"start": "3.x.x"
1313
},
1414
"dependencies": {
15+
"decamelize": "1.x.x",
1516
"chalk": "1.x.x",
16-
"decamelize": "1.x.x"
17+
"stack-utils": "0.x.x"
1718
},
1819
"devDependencies": {
1920
"husky": "0.10.x",

0 commit comments

Comments
 (0)