Skip to content

Commit

Permalink
feat: improve at-path stack trace formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Nov 13, 2017
1 parent d921d73 commit c8d33a7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/LineWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const formatFailureMessageTraceLine = require('./format/formatFailureMessageTrac

const REG_TRACE_LINE = /\s*(.+)\((.+):([0-9]+):([0-9]+)\)$/;
const REG_INTERNALS = /^(node_modules|internal)\//;
const REG_AT_PATH = /^\s*at (\/[^:]+):([0-9]+):([0-9]+)\s*$/;
const REG_AT = /^\s*at/;
const REG_ERROR = /^\s*Error:\s*/;
const REG_RECEIVED = /^\s*Received:/;
Expand Down Expand Up @@ -233,7 +234,16 @@ class LineWriter {
}
}
} else {
pushTraceLine(line);
const atPathMatches = line.match(REG_AT_PATH);
const pushMethod = internalsStarted ? pushTraceLineDim : pushTraceLine;

if (atPathMatches) {
const [, atPathPath, atPathRow, atPathColumn] = atPathMatches;

pushMethod(chalk`at {cyan ${this.getPathRelativeToRoot(atPathPath)}}:{bold ${atPathRow}}:{bold ${atPathColumn}}`);
} else {
pushMethod(line);
}
}
} else {
// eslint-disable-next-line no-lonely-if
Expand Down

0 comments on commit c8d33a7

Please sign in to comment.