@@ -26,13 +26,16 @@ export class Addon {
2626 #enabled?: boolean [ ] ;
2727 /** Whether or not this addon has an update available from git. */
2828 #hasUpdate?: boolean ;
29+ /** Whether or not this addon is installed */
30+ #installed: boolean ;
2931
3032 constructor ( name : string , path : vscode . Uri ) {
3133 this . name = name ;
3234 this . uri = path ;
3335
3436 this . #enabled = [ ] ;
3537 this . #hasUpdate = false ;
38+ this . #installed = false ;
3639 }
3740
3841 /** Fetch addon info from `info.json` */
@@ -106,6 +109,10 @@ export class Addon {
106109 ( entry ) => ( this . #enabled[ entry . folder . index ] = entry . enabled )
107110 ) ;
108111
112+ this . #installed = await filesystem . exists (
113+ vscode . Uri . joinPath ( this . uri , "module" )
114+ ) ;
115+
109116 return folderStates ;
110117 }
111118
@@ -192,22 +199,24 @@ export class Addon {
192199 return ;
193200 }
194201
195- // Remove submodule
196- // try {
197- // const moduleURI = vscode.Uri.joinPath(this.uri, "module");
198- // await filesystem.deleteFile(moduleURI, {
199- // recursive: true,
200- // useTrash: false,
201- // });
202- // } catch (e) {
203- // localLogger.error(`Failed to uninstall "${this.name}"`);
204- // return;
205- // }
206-
207202 this . #enabled[ folder . index ] = false ;
208203 localLogger . info ( `Disabled "${ this . name } "` ) ;
209204 }
210205
206+ public async uninstall ( ) {
207+ for ( const folder of vscode . workspace . workspaceFolders ) {
208+ await this . disable ( folder ) ;
209+ }
210+ const moduleURI = vscode . Uri . joinPath ( this . uri , "module" ) ;
211+ await filesystem . deleteFile ( moduleURI , {
212+ recursive : true ,
213+ useTrash : false ,
214+ } ) ;
215+ localLogger . info ( `Uninstalled ${ this . name } ` ) ;
216+ this . #installed = false ;
217+ this . setLock ( false ) ;
218+ }
219+
211220 /** Convert this addon to an object ready for sending to WebVue. */
212221 public async toJSON ( ) {
213222 await this . getEnabled ( ) ;
@@ -227,6 +236,7 @@ export class Addon {
227236 size,
228237 hasUpdate,
229238 processing : this . #processing,
239+ installed : this . #installed,
230240 } ;
231241 }
232242
0 commit comments