File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 2
2
var StackUtils = require ( 'stack-utils' ) ;
3
3
var debug = require ( 'debug' ) ( 'ava' ) ;
4
4
5
+ //-----------
6
+ // embedded `clean-stack` module (because it requires Node.js 4)
7
+ var extractPathRegex = / \s + a t .* (?: \( | \s ) ( .* ) \) ? / ;
8
+ var pathRegex = / ^ (?: (?: (?: n o d e | (?: i n t e r n a l \/ [ \w / ] * | .* n o d e _ m o d u l e s \/ b a b e l - p o l y f i l l \/ .* ) ? \w + ) \. j s : \d + : \d + ) | n a t i v e ) / ;
9
+
10
+ var cleanStack = function ( stack ) {
11
+ return stack . replace ( / \\ / g, '/' ) . split ( '\n' ) . filter ( function ( x ) {
12
+ var pathMatches = x . match ( extractPathRegex ) ;
13
+ if ( pathMatches === null || ! pathMatches [ 1 ] ) {
14
+ return true ;
15
+ }
16
+
17
+ return ! pathRegex . test ( pathMatches [ 1 ] ) ;
18
+ } ) . filter ( function ( x ) {
19
+ return x . trim ( ) !== '' ;
20
+ } ) . join ( '\n' ) ;
21
+ } ;
22
+ //-----------
23
+
5
24
function indent ( str ) {
6
25
return ' ' + str ;
7
26
}
@@ -25,6 +44,10 @@ module.exports = function (stack) {
25
44
return '' ;
26
45
}
27
46
47
+ // workaround for https://github.com/tapjs/stack-utils/issues/14
48
+ // TODO: fix it in `stack-utils`
49
+ stack = cleanStack ( stack ) ;
50
+
28
51
var title = stack . split ( '\n' ) [ 0 ] ;
29
52
var lines = stackUtils
30
53
. clean ( stack )
You can’t perform that action at this time.
0 commit comments