@@ -169,7 +169,6 @@ export const sortLines = (output: string) =>
169169 . split ( '\n' )
170170 . sort ( )
171171 . map ( str => str . trim ( ) )
172- . filter ( Boolean )
173172 . join ( '\n' ) ;
174173
175174const DEFAULT_PACKAGE_JSON : PackageJson = {
@@ -222,21 +221,20 @@ export const extractSummary = (stdout: string) => {
222221const sortTests = ( stdout : string ) =>
223222 stdout
224223 . split ( '\n' )
225- . reduce ( ( tests : Array < Array < string > > , line ) => {
224+ . reduce < Array < Array < string > > > ( ( tests , line ) => {
226225 if ( [ 'RUNS' , 'PASS' , 'FAIL' ] . includes ( line . slice ( 0 , 4 ) ) ) {
227- tests . push ( [ line . trimRight ( ) ] ) ;
228- } else if ( line ) {
229- tests [ tests . length - 1 ] . push ( line . trimRight ( ) ) ;
226+ tests . push ( [ line ] ) ;
227+ } else {
228+ tests [ tests . length - 1 ] . push ( line ) ;
230229 }
231230 return tests ;
232231 } , [ ] )
233232 . sort ( ( [ a ] , [ b ] ) => ( a > b ? 1 : - 1 ) )
234- . reduce (
235- ( array , lines = [ ] ) =>
236- lines . length > 1 ? array . concat ( lines , '' ) : array . concat ( lines ) ,
237- [ ] ,
233+ . map ( strings =>
234+ strings . length > 1 ? `${ strings . join ( '\n' ) . trimRight ( ) } \n` : strings [ 0 ] ,
238235 )
239- . join ( '\n' ) ;
236+ . join ( '\n' )
237+ . trim ( ) ;
240238
241239export const extractSortedSummary = ( stdout : string ) => {
242240 const { rest, summary} = extractSummary ( stdout ) ;
@@ -280,6 +278,17 @@ export const normalizeIcons = (str: string) => {
280278 . replace ( new RegExp ( '\u221A' , 'g' ) , '\u2713' ) ;
281279} ;
282280
281+ export const rightTrimStdout = ( str : string ) => {
282+ if ( ! str ) {
283+ return str ;
284+ }
285+
286+ return str
287+ . split ( '\n' )
288+ . map ( str => str . trimRight ( ) )
289+ . join ( '\n' ) ;
290+ } ;
291+
283292// Certain environments (like CITGM and GH Actions) do not come with mercurial installed
284293let hgIsInstalled : boolean | null = null ;
285294
0 commit comments