File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -42,10 +42,22 @@ const { file } = cli.flags;
4242 } else {
4343 str = await clipboardy . read ( ) ;
4444 }
45- const stack = stackTraceParser . parse ( str ) ;
46- if ( stack . length === 0 ) throw new Error ( 'No stack found' ) ;
4745
48- const header = str . split ( '\n' ) . find ( line => line . trim ( ) . length > 0 ) ;
46+ let [ header , ...lines ] = str . trim ( ) . split ( / \r ? \n / ) ;
47+
48+ lines = lines . map ( ( line ) => {
49+ // stacktrace-parser doesn't seem to support stacktrace lines like this:
50+ // index-12345678.js:1:2 a
51+ const match = line . match ( / ^ ( \s + ) ( [ ^ \s ] + : \d + : \d + ) \s + ( [ ^ \s ] + ) $ / ) ;
52+ if ( match ) {
53+ return `${ match [ 1 ] } at ${ match [ 3 ] } (${ match [ 2 ] } )` ;
54+ }
55+
56+ return line ;
57+ } )
58+
59+ const stack = stackTraceParser . parse ( lines . join ( '\n' ) ) ;
60+ if ( stack . length === 0 ) throw new Error ( 'No stack found' ) ;
4961
5062 if ( header ) console . log ( header ) ;
5163
You can’t perform that action at this time.
0 commit comments