@@ -5,7 +5,6 @@ import * as tar from 'tar';
55import axios from 'axios' ;
66import * as unzipper from 'unzipper' ;
77import { Semaphore } from 'async-mutex' ;
8- import * as os from "os" ;
98import { logger } from "../wrapper/loggerConfig" ;
109import { finished } from 'stream/promises' ;
1110
@@ -56,12 +55,21 @@ export class CxInstaller {
5655 return ;
5756 }
5857 const url = await this . getDownloadURL ( ) ;
59- const zipPath = path . join ( os . tmpdir ( ) , `ast-cli. ${ this . platform === 'win32' ? 'zip' : 'tar.gz' } ` ) ;
58+ const zipPath = path . join ( this . resourceDirPath , this . getCompressFolderName ( ) ) ;
6059
6160 await this . downloadFile ( url , zipPath ) ;
6261 logger . info ( 'Downloaded CLI to:' , zipPath ) ;
6362
6463 await this . extractArchive ( zipPath , this . resourceDirPath ) ;
64+
65+ fs . unlink ( zipPath , ( err ) => {
66+ if ( err ) {
67+ logger . error ( 'Error deleting the file:' , err ) ;
68+ } else {
69+ logger . info ( 'File deleted successfully!' ) ;
70+ }
71+ } ) ;
72+
6573 fs . chmodSync ( this . getExecutablePath ( ) , 0o755 ) ;
6674 logger . info ( 'Extracted CLI to:' , this . resourceDirPath ) ;
6775 } catch ( error ) {
@@ -109,4 +117,8 @@ export class CxInstaller {
109117 return this . cliDefaultVersion ;
110118 }
111119 }
120+
121+ getCompressFolderName ( ) : string {
122+ return `ast-cli.${ this . platform === 'win32' ? 'zip' : 'tar.gz' } ` ;
123+ }
112124}
0 commit comments