@@ -5,7 +5,6 @@ import * as tar from 'tar';
5
5
import axios from 'axios' ;
6
6
import * as unzipper from 'unzipper' ;
7
7
import { Semaphore } from 'async-mutex' ;
8
- import * as os from "os" ;
9
8
import { logger } from "../wrapper/loggerConfig" ;
10
9
import { finished } from 'stream/promises' ;
11
10
@@ -56,12 +55,21 @@ export class CxInstaller {
56
55
return ;
57
56
}
58
57
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 ( ) ) ;
60
59
61
60
await this . downloadFile ( url , zipPath ) ;
62
61
logger . info ( 'Downloaded CLI to:' , zipPath ) ;
63
62
64
63
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
+
65
73
fs . chmodSync ( this . getExecutablePath ( ) , 0o755 ) ;
66
74
logger . info ( 'Extracted CLI to:' , this . resourceDirPath ) ;
67
75
} catch ( error ) {
@@ -109,4 +117,8 @@ export class CxInstaller {
109
117
return this . cliDefaultVersion ;
110
118
}
111
119
}
120
+
121
+ getCompressFolderName ( ) : string {
122
+ return `ast-cli.${ this . platform === 'win32' ? 'zip' : 'tar.gz' } ` ;
123
+ }
112
124
}
0 commit comments