Skip to content

Commit

Permalink
feat: display path relative to root dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Dalecky authored and Vadim Dalecky committed Nov 7, 2017
1 parent 81ff976 commit d75e1be
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/TapReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ class TapReporter {
this.onAssertionResult = this.onAssertionResult.bind(this);
}

pathRelativeToRoot (filePath) {
return path.relative(this._globalConfig.rootDir, filePath);
}

formatFailureMessageTraceLine (line) {
const matches = line.match(REG_TRACE_LINE);

if (matches) {
const [, description, file, row, column] = matches;

return chalk`${description}({cyan ${file}}:{black.bold ${row}}:{black.bold ${column}})`;
return chalk`${description}({cyan ${this.pathRelativeToRoot(file)}}:{black.bold ${row}}:{black.bold ${column}})`;
} else {
return line;
}
Expand Down Expand Up @@ -118,7 +122,7 @@ class TapReporter {
const label = numFailingTests > 0 ?
chalk`{bgRed.bold.rgb(255,255,255) FAIL }` :
chalk`{bgGreen.bold.rgb(255,255,255) PASS }`;
const tapLine = chalk`${prefix}{hidden #} ${label} {grey ${dir}${path.sep}}{bold ${base}}`;
const tapLine = chalk`${prefix}{hidden #} ${label} {grey ${this.pathRelativeToRoot(dir)}${path.sep}}{bold ${base}}`;

this.logger.info(tapLine + '\n');
}
Expand Down

0 comments on commit d75e1be

Please sign in to comment.