@@ -23,7 +23,9 @@ export class CommandInvocationError extends Error {
23
23
if ( fatalErrors ) {
24
24
message =
25
25
`Encountered a fatal error while running "${ prettyCommand } ". ` +
26
- `Exit code was ${ exitCode } and error was: ${ fatalErrors . trim ( ) } See the logs for more details.` ;
26
+ `Exit code was ${ exitCode } and error was: ${ ensureEndsInPeriod (
27
+ fatalErrors . trim ( ) ,
28
+ ) } See the logs for more details.`;
27
29
} else if ( autobuildErrors ) {
28
30
const autobuildHelpLink =
29
31
"https://docs.github.com/en/code-security/code-scanning/troubleshooting-code-scanning/automatic-build-failed" ;
@@ -32,10 +34,9 @@ export class CommandInvocationError extends Error {
32
34
`For more information, see ${ autobuildHelpLink } . ` +
33
35
`Encountered the following error: ${ autobuildErrors } ` ;
34
36
} else {
35
- let lastLine = stderr . trim ( ) . split ( "\n" ) . pop ( ) ?. trim ( ) || "" ;
36
- if ( lastLine [ lastLine . length - 1 ] !== "." ) {
37
- lastLine += "." ;
38
- }
37
+ const lastLine = ensureEndsInPeriod (
38
+ stderr . trim ( ) . split ( "\n" ) . pop ( ) ?. trim ( ) || "n/a" ,
39
+ ) ;
39
40
message =
40
41
`Encountered a fatal error while running "${ prettyCommand } ". ` +
41
42
`Exit code was ${ exitCode } and last log line was: ${ lastLine } See the logs for more details.` ;
@@ -75,7 +76,7 @@ export class CommandInvocationError extends Error {
75
76
* the Actions UI.
76
77
*/
77
78
function extractFatalErrors ( error : string ) : string | undefined {
78
- const fatalErrorRegex = / .* f a t a l e r r o r o c c u r r e d : / gi;
79
+ const fatalErrorRegex = / .* f a t a l ( i n t e r n a l ) ? e r r o r o c c u r r ? e d ( . D e t a i l s ) ? : / gi;
79
80
let fatalErrors : string [ ] = [ ] ;
80
81
let lastFatalErrorIndex : number | undefined ;
81
82
let match : RegExpMatchArray | null ;
0 commit comments