@@ -215,7 +215,7 @@ async function downloadCli(
215215 }
216216
217217 await new Promise < void > ( ( resolve , reject ) => {
218- writeStream . end ( ( err : Error | null | undefined ) => {
218+ writeStream . close ( ( err : Error | null | undefined ) => {
219219 if ( err ) reject ( err ) ;
220220 else resolve ( ) ;
221221 } ) ;
@@ -259,18 +259,27 @@ async function downloadCli(
259259 }
260260}
261261
262- // tar is built-in on Windows 10+, macOS, and Linux
262+ // tar is built-in on Windows 10+, macOS, and Linux and handles .zip and .tar.gz
263263async function extractArchive ( archivePath : string , destDir : string ) : Promise < void > {
264264 return new Promise ( ( resolve , reject ) => {
265- const proc = spawn ( "tar" , [ "-xf" , archivePath , "-C" , destDir ] , { stdio : "ignore" } ) ;
265+ const proc = spawn ( "tar" , [ "-xf" , archivePath , "-C" , destDir ] , { stdio : "pipe" } ) ;
266+
267+ let stderr = "" ;
268+ proc . stderr ?. on ( "data" , ( data ) => {
269+ stderr += data . toString ( ) ;
270+ } ) ;
266271
267272 proc . on ( "error" , reject ) ;
268273 proc . on ( "exit" , ( code ) => {
269274 if ( code === 0 ) resolve ( ) ;
270- else
275+ else {
276+ const msg = stderr ? `: ${ stderr . trim ( ) } ` : "" ;
271277 reject (
272- new Error ( `Archive extraction failed for ${ archivePath } (exit code ${ code } )` )
278+ new Error (
279+ `Archive extraction failed for ${ archivePath } (exit code ${ code } )${ msg } `
280+ )
273281 ) ;
282+ }
274283 } ) ;
275284 } ) ;
276285}
0 commit comments