@@ -20,8 +20,8 @@ export type TarVersion = {
20
20
version : string ;
21
21
} ;
22
22
23
- async function getTarVersion ( ) : Promise < TarVersion > {
24
- const tar = await io . which ( "tar" , true ) ;
23
+ async function getTarVersion ( programName : string ) : Promise < TarVersion > {
24
+ const tar = await io . which ( programName , true ) ;
25
25
let stdout = "" ;
26
26
const exitCode = await new ToolRunner ( tar , [ "--version" ] , {
27
27
listeners : {
@@ -31,23 +31,23 @@ async function getTarVersion(): Promise<TarVersion> {
31
31
} ,
32
32
} ) . exec ( ) ;
33
33
if ( exitCode !== 0 ) {
34
- throw new Error ( " Failed to call tar --version" ) ;
34
+ throw new Error ( ` Failed to call ${ programName } --version` ) ;
35
35
}
36
36
// Return whether this is GNU tar or BSD tar, and the version number
37
37
if ( stdout . includes ( "GNU tar" ) ) {
38
38
const match = stdout . match ( / t a r \( G N U t a r \) ( [ 0 - 9 . ] + ) / ) ;
39
39
if ( ! match || ! match [ 1 ] ) {
40
- throw new Error ( " Failed to parse output of tar --version." ) ;
40
+ throw new Error ( ` Failed to parse output of ${ programName } --version.` ) ;
41
41
}
42
42
43
- return { name : "tar" , type : "gnu" , version : match [ 1 ] } ;
43
+ return { name : programName , type : "gnu" , version : match [ 1 ] } ;
44
44
} else if ( stdout . includes ( "bsdtar" ) ) {
45
45
const match = stdout . match ( / b s d t a r ( [ 0 - 9 . ] + ) / ) ;
46
46
if ( ! match || ! match [ 1 ] ) {
47
- throw new Error ( " Failed to parse output of tar --version." ) ;
47
+ throw new Error ( ` Failed to parse output of ${ programName } --version.` ) ;
48
48
}
49
49
50
- return { name : "tar" , type : "bsd" , version : match [ 1 ] } ;
50
+ return { name : programName , type : "bsd" , version : match [ 1 ] } ;
51
51
} else {
52
52
throw new Error ( "Unknown tar version" ) ;
53
53
}
@@ -64,7 +64,7 @@ export async function isZstdAvailable(
64
64
) : Promise < ZstdAvailability > {
65
65
const foundZstdBinary = await isBinaryAccessible ( "zstd" , logger ) ;
66
66
try {
67
- const tarVersion = await getTarVersion ( ) ;
67
+ const tarVersion = await getTarVersion ( "tar" ) ;
68
68
const { type, version } = tarVersion ;
69
69
logger . info ( `Found ${ type } tar version ${ version } .` ) ;
70
70
switch ( type ) {
0 commit comments