@@ -10,6 +10,7 @@ import {logger} from "../wrapper/loggerConfig";
10
10
import { finished } from 'stream/promises' ;
11
11
12
12
type SupportedPlatforms = 'win32' | 'darwin' | 'linux' ;
13
+
13
14
export class CxInstaller {
14
15
private readonly platform : string ;
15
16
private cliVersion : string ;
@@ -26,9 +27,9 @@ export class CxInstaller {
26
27
const cliVersion = await this . readASTCLIVersion ( ) ;
27
28
28
29
const platforms : Record < SupportedPlatforms , { platform : string ; extension : string } > = {
29
- win32 : { platform : 'windows' , extension : 'zip' } ,
30
- darwin : { platform : 'darwin' , extension : 'tar.gz' } ,
31
- linux : { platform : 'linux' , extension : 'tar.gz' }
30
+ win32 : { platform : 'windows' , extension : 'zip' } ,
31
+ darwin : { platform : 'darwin' , extension : 'tar.gz' } ,
32
+ linux : { platform : 'linux' , extension : 'tar.gz' }
32
33
} ;
33
34
34
35
const platformKey = this . platform as SupportedPlatforms ;
@@ -42,23 +43,18 @@ export class CxInstaller {
42
43
}
43
44
44
45
getExecutablePath ( ) : string {
45
- let executablePath ;
46
- if ( this . platform === 'win32' ) {
47
- executablePath = path . join ( this . resourceDirPath , 'cx.exe' ) ;
48
- } else {
49
- executablePath = path . join ( this . resourceDirPath , 'cx' ) ;
50
- }
51
- return executablePath ;
46
+ const executableName = this . platform === 'win32' ? 'cx.exe' : 'cx' ;
47
+ return path . join ( this . resourceDirPath , executableName ) ;
52
48
}
53
49
50
+
54
51
async downloadIfNotInstalledCLI ( ) : Promise < void > {
55
52
const [ _ , release ] = await CxInstaller . installSemaphore . acquire ( ) ;
56
53
try {
57
54
if ( this . checkExecutableExists ( ) ) {
58
55
logger . info ( 'Executable already installed.' ) ;
59
56
return ;
60
57
}
61
-
62
58
const url = await this . getDownloadURL ( ) ;
63
59
const zipPath = path . join ( os . tmpdir ( ) , `ast-cli.${ this . platform === 'win32' ? 'zip' : 'tar.gz' } ` ) ;
64
60
0 commit comments