@@ -16,11 +16,20 @@ const MIN_REQUIRED_GNU_TAR_VERSION = "1.31";
16
16
17
17
export type TarVersion = {
18
18
type : "gnu" | "bsd" ;
19
+ name : string ;
19
20
version : string ;
20
21
} ;
21
22
22
23
async function getTarVersion ( ) : Promise < TarVersion > {
23
- const tar = await io . which ( "tar" , true ) ;
24
+ let tarName = "" ;
25
+ let tar = "" ;
26
+ try {
27
+ tarName = "gtar" ;
28
+ tar = await io . which ( tarName , true ) ;
29
+ } catch {
30
+ tarName = "tar" ;
31
+ tar = await io . which ( tarName , true ) ;
32
+ }
24
33
let stdout = "" ;
25
34
const exitCode = await new ToolRunner ( tar , [ "--version" ] , {
26
35
listeners : {
@@ -39,14 +48,14 @@ async function getTarVersion(): Promise<TarVersion> {
39
48
throw new Error ( "Failed to parse output of tar --version." ) ;
40
49
}
41
50
42
- return { type : "gnu" , version : match [ 1 ] } ;
51
+ return { type : "gnu" , name : tarName , version : match [ 1 ] } ;
43
52
} else if ( stdout . includes ( "bsdtar" ) ) {
44
53
const match = stdout . match ( / b s d t a r ( [ 0 - 9 . ] + ) / ) ;
45
54
if ( ! match || ! match [ 1 ] ) {
46
55
throw new Error ( "Failed to parse output of tar --version." ) ;
47
56
}
48
57
49
- return { type : "bsd" , version : match [ 1 ] } ;
58
+ return { type : "bsd" , name : tarName , version : match [ 1 ] } ;
50
59
} else {
51
60
throw new Error ( "Unknown tar version" ) ;
52
61
}
@@ -162,10 +171,10 @@ export async function extractTarZst(
162
171
163
172
args . push ( "-f" , tar instanceof stream . Readable ? "-" : tar , "-C" , dest ) ;
164
173
165
- process . stdout . write ( `[command]tar ${ args . join ( " " ) } \n` ) ;
174
+ process . stdout . write ( `[command]${ tarVersion . name } ${ args . join ( " " ) } \n` ) ;
166
175
167
176
await new Promise < void > ( ( resolve , reject ) => {
168
- const tarProcess = spawn ( "tar" , args , { stdio : "pipe" } ) ;
177
+ const tarProcess = spawn ( tarVersion . name , args , { stdio : "pipe" } ) ;
169
178
170
179
let stdout = "" ;
171
180
tarProcess . stdout ?. on ( "data" , ( data : Buffer ) => {
@@ -196,7 +205,7 @@ export async function extractTarZst(
196
205
if ( code !== 0 ) {
197
206
reject (
198
207
new CommandInvocationError (
199
- "tar" ,
208
+ tarVersion . name ,
200
209
args ,
201
210
code ?? undefined ,
202
211
stdout ,
0 commit comments