Skip to content

Commit e26cacd

Browse files
committed
correctly clean next_tick stack output
1 parent 9e48eaf commit e26cacd

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const extractPathRegex = /\s+at.*(?:\(|\s)(.*)\)?/;
4-
const pathRegex = /^(?:(?:(?:node|(?:internal\/|.*node_modules\/babel-polyfill\/.*)?\w+)\.js:\d+:\d+)|native)/;
4+
const pathRegex = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/babel-polyfill\/.*)?\w+)\.js:\d+:\d+)|native)/;
55

66
module.exports = stack => {
77
return stack.replace(/\\/g, '/')

test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ test('internal child_process', t => {
4444
t.is(m(stack), pre);
4545
});
4646

47+
test('internal next_tick', t => {
48+
const pre = 'Error: foo\n at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:4:7)';
49+
const stack = `${pre}\n
50+
at _combinedTickCallback (internal/process/next_tick.js:67:7)
51+
at process._tickCallback (internal/process/next_tick.js:98:9)`;
52+
t.is(m(stack), pre);
53+
});
54+
4755
test('babel-polyfill', t => {
4856
const pre = 'Error: foo\n at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:4:7)';
4957
const stack = `${pre}\n

0 commit comments

Comments
 (0)