@@ -10,6 +10,7 @@ import {logger} from "../wrapper/loggerConfig";
1010import { finished } from 'stream/promises' ;
1111
1212type SupportedPlatforms = 'win32' | 'darwin' | 'linux' ;
13+
1314export class CxInstaller {
1415 private readonly platform : string ;
1516 private cliVersion : string ;
@@ -26,9 +27,9 @@ export class CxInstaller {
2627 const cliVersion = await this . readASTCLIVersion ( ) ;
2728
2829 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' }
3233 } ;
3334
3435 const platformKey = this . platform as SupportedPlatforms ;
@@ -42,23 +43,18 @@ export class CxInstaller {
4243 }
4344
4445 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 ) ;
5248 }
5349
50+
5451 async downloadIfNotInstalledCLI ( ) : Promise < void > {
5552 const [ _ , release ] = await CxInstaller . installSemaphore . acquire ( ) ;
5653 try {
5754 if ( this . checkExecutableExists ( ) ) {
5855 logger . info ( 'Executable already installed.' ) ;
5956 return ;
6057 }
61-
6258 const url = await this . getDownloadURL ( ) ;
6359 const zipPath = path . join ( os . tmpdir ( ) , `ast-cli.${ this . platform === 'win32' ? 'zip' : 'tar.gz' } ` ) ;
6460
0 commit comments