@@ -428,13 +428,13 @@ export class TaskRunner {
428428 }
429429
430430 if ( task . writer ) {
431- let stderr : string = task . writer . getStdError ( ) ;
432- if ( stderr && ( task . status === TaskStatus . Failure || task . status === TaskStatus . SuccessWithWarning ) ) {
433- stderr = stderr . split ( os . EOL )
434- . map ( text => text . trim ( ) )
435- . filter ( text => text )
436- . join ( os . EOL ) ;
437- this . _terminal . writeLine ( stderr + ( i !== tasks . length - 1 ? os . EOL : '' ) ) ;
431+ const stderr : string = task . writer . getStdError ( ) ;
432+ const shouldPrintDetails : boolean =
433+ task . status === TaskStatus . Failure || task . status === TaskStatus . SuccessWithWarning ;
434+ let details : string = stderr ? stderr : task . writer . getStdOutput ( ) ;
435+ if ( details && shouldPrintDetails ) {
436+ details = this . _abridgeTaskReport ( details ) ;
437+ this . _terminal . writeLine ( details + ( i !== tasks . length - 1 ? os . EOL : '' ) ) ;
438438 }
439439 }
440440 }
@@ -443,4 +443,21 @@ export class TaskRunner {
443443 }
444444 }
445445
446+ /**
447+ * Remove trailing blanks, and all middle lines if text is large
448+ */
449+ private _abridgeTaskReport ( text : string ) : string {
450+ const headSize : number = 10 ;
451+ const tailSize : number = 20 ;
452+ const margin : number = 10 ;
453+ const lines : Array < string > = text . split ( / \s * \r ? \n / ) . filter ( line => line ) ;
454+ if ( lines . length < headSize + tailSize + margin ) {
455+ return lines . join ( os . EOL ) ;
456+ }
457+ const amountRemoved : number = lines . length - headSize - tailSize ;
458+ const head : string = lines . splice ( 0 , headSize ) . join ( os . EOL ) ;
459+ const tail : string = lines . splice ( - tailSize ) . join ( os . EOL ) ;
460+ return `${ head } ${ os . EOL } [...${ amountRemoved } lines omitted...]${ os . EOL } ${ tail } ` ;
461+ }
462+
446463}
0 commit comments