@@ -19,6 +19,13 @@ interface EffektExecutableInfo {
1919 version : string ;
2020}
2121
22+ export class EffektExecutableNotFoundError extends Error {
23+ constructor ( message : string = "Effekt executable not found" ) {
24+ super ( message ) ;
25+ this . name = "EffektExecutableNotFoundError" ;
26+ }
27+ }
28+
2229/**
2330 * Manages Effekt installation, updates, and status within VS Code.
2431 */
@@ -171,7 +178,7 @@ export class EffektManager {
171178 }
172179 }
173180
174- throw new Error ( 'Effekt executable not found' ) ;
181+ throw new EffektExecutableNotFoundError ( 'Effekt executable not found' ) ;
175182 }
176183
177184 /**
@@ -180,7 +187,7 @@ export class EffektManager {
180187 * @param action The action being performed ('install' or 'update').
181188 * @returns A promise that resolves with the installed/updated version or an empty string.
182189 */
183- private async installOrUpdateEffekt ( version : string , action : 'install' | 'update' , client : EffektLanguageClient ) : Promise < string > {
190+ private async installOrUpdateEffekt ( version : string , action : 'install' | 'update' , client ? : EffektLanguageClient ) : Promise < string > {
184191 if ( ! ( await this . checkJava ( ) ) ) {
185192 this . logMessage ( 'INFO' , 'Java is not installed.' ) ;
186193 return '' ;
@@ -196,10 +203,9 @@ export class EffektManager {
196203 cancellable : false
197204 } , async ( progress ) => {
198205 try {
199- console . log ( "Right before the try stop" )
200- await client . stop ( 10000 )
201- console . log ( "right after the try - stop" )
202-
206+ if ( client ) {
207+ await client . stop ( ) ;
208+ }
203209 progress . report ( { increment : 0 , message : 'Preparing...' } ) ;
204210 await this . runNpmInstall ( ) ;
205211 progress . report ( { increment : 50 , message : 'Verifying installation...' } ) ;
@@ -208,19 +214,18 @@ export class EffektManager {
208214 progress . report ( { increment : 100 , message : 'Completed' } ) ;
209215
210216 this . handleInstallationResult ( verificationResult , action ) ;
211- console . log ( "right before the try start" )
212- await client . start ( ) ;
213- console . log ( "right after the try start" )
214-
217+
218+ if ( client ) {
219+ await client . start ( ) ;
220+ }
215221 return verificationResult . success ? verificationResult . version || '' : '' ;
216222 } catch ( error ) {
217223 this . showErrorWithLogs ( `Failed to ${ action } Effekt: ${ error } ` ) ;
218224 this . updateStatusBar ( ) ;
219- console . log ( "right before the catch start" )
220-
221- await client . start ( ) ;
222- console . log ( "right after the catch start" )
223225
226+ if ( client ) {
227+ await client . start ( ) ;
228+ }
224229 return '' ;
225230 }
226231 } ) ;
@@ -329,14 +334,14 @@ export class EffektManager {
329334 * Checks for Effekt updates and offers to install/update if necessary.
330335 * @returns A promise that resolves with the current Effekt version.
331336 */
332- public async checkForUpdatesAndInstall ( client : EffektLanguageClient ) : Promise < string > {
337+ public async checkForUpdatesAndInstall ( client ? : EffektLanguageClient ) : Promise < string > {
333338 try {
334339 let currentVersion = await this . getEffektVersion ( ) ;
335340 const latestVersion = await this . getLatestNPMVersion ( this . effektNPMPackage ) ;
336341
337342 // check if the latest version strictly newer than the current version
338343 if ( ! currentVersion || compareVersion ( latestVersion , currentVersion , '>' ) ) {
339- return this . promptForAction ( latestVersion , 'update' , client ) ;
344+ return this . promptForAction ( latestVersion , 'update' , client ) ;
340345 } else {
341346 vscode . window . showInformationMessage ( `Effekt is up-to-date (version ${ currentVersion } ).` ) ;
342347 }
@@ -360,7 +365,7 @@ export class EffektManager {
360365 * @param action The action to perform ('install' or 'update').
361366 * @returns A promise that resolves with the installed/updated version or an empty string.
362367 */
363- private async promptForAction ( version : string , action : 'install' | 'update' , client : EffektLanguageClient ) : Promise < string > {
368+ private async promptForAction ( version : string , action : 'install' | 'update' , client ? : EffektLanguageClient ) : Promise < string > {
364369 const message = action === 'update'
365370 ? `A new version of Effekt is available (${ version } ). Would you like to update?`
366371 : `Effekt ${ version } is available. Would you like to install it?` ;
0 commit comments