Skip to content
This repository was archived by the owner on Jul 9, 2021. It is now read-only.

Commit 1090c8f

Browse files
committed
[changed] display relative file paths when logging errors
1 parent 5802023 commit 1090c8f

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/logger.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import transform from 'lodash/transform';
77
import ErrorStackParser from 'error-stack-parser';
88
import cleanStack from 'clean-stack';
99
import {isNode} from './util';
10+
import {relative} from 'path';
1011

1112
/* eslint-disable no-console */
1213

@@ -253,7 +254,7 @@ export function formatLine(message: string, file: string, line: number | string,
253254
column: number | string): Array<string | Message> {
254255
const {yellow, cyan, magenta} = consoleStyles;
255256

256-
return ['"', yellow(message), '" in ', cyan(file), ' on ', magenta(line), ':', magenta(column)];
257+
return ['"', yellow(message), '" in ', cyan(relative('', file)), ' on ', magenta(line), ':', magenta(column)];
257258
}
258259

259260
/**

test/logger.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {spy, stub, match} from 'sinon';
55
import sinonChai from 'sinon-chai';
66
import * as logger from '../src/logger';
77
import * as util from '../src/util';
8+
import path from 'path';
89

910
chai.use(sinonChai);
1011

@@ -116,10 +117,12 @@ describe('logger', () => {
116117

117118
beforeEach(() => {
118119
stub(console, 'log');
120+
stub(path, 'relative').returnsArg(1);
119121
});
120122

121123
afterEach(() => {
122124
console.log.restore();
125+
path.relative.restore();
123126
});
124127

125128
it('log', () => {

0 commit comments

Comments
 (0)