@@ -35,23 +35,31 @@ function getExtensionPath(extension: IExtensionDefinition): string {
35
35
36
36
function isUpToDate ( extension : IExtensionDefinition ) : boolean {
37
37
const regex = new RegExp ( `^${ extension . name } -(\\d+\\.\\d+\\.\\d+)\\.vsix$` ) ;
38
- if ( ! fs . existsSync ( path . join ( root , '.build' , 'bootstrapExtensions' ) ) ) {
38
+ const bootstrapDir = path . join ( root , '.build' , 'bootstrapExtensions' ) ;
39
+ if ( ! fs . existsSync ( bootstrapDir ) ) {
39
40
return false ;
40
41
}
41
- const files = fs . readdirSync ( path . join ( root , '.build' , 'bootstrapExtensions' ) ) ;
42
- const vsixPath = files . find ( f => regex . test ( f ) ) ;
43
42
44
- if ( ! vsixPath ) {
45
- return false ;
46
- }
47
-
48
- try {
49
- const match = vsixPath . match ( regex ) ;
50
- const diskVersion = match ? match [ 1 ] : null ;
51
- return ( diskVersion === extension . version ) ;
52
- } catch ( err ) {
53
- return false ;
43
+ const files = fs . readdirSync ( bootstrapDir ) ;
44
+ const matchingFiles = files . filter ( f => regex . test ( f ) ) ;
45
+ for ( const vsixPath of matchingFiles ) {
46
+ try {
47
+ const match = vsixPath . match ( regex ) ;
48
+ const diskVersion = match ? match [ 1 ] : null ;
49
+
50
+ if ( diskVersion !== extension . version ) {
51
+ log ( `[extensions]` , `Outdated version detected, deleting ${ vsixPath } ` ) ;
52
+ fs . unlinkSync ( path . join ( bootstrapDir , vsixPath ) ) ;
53
+ } else {
54
+ log ( `[extensions]` , `Found up-to-date extension: ${ vsixPath } ` ) ;
55
+ return true ;
56
+ }
57
+ } catch ( err ) {
58
+ log ( `[extensions]` , `Error checking version of ${ vsixPath } ` , err ) ;
59
+ return false ;
60
+ }
54
61
}
62
+ return false ;
55
63
}
56
64
57
65
function getExtensionDownloadStream ( extension : IExtensionDefinition ) {
0 commit comments