@@ -67,13 +67,30 @@ export class ServerComponent {
67
67
const instance = getInstance ( ) ;
68
68
const connection = instance . getConnection ( ) ;
69
69
70
+ if ( ! connection ) {
71
+ return false ;
72
+ }
73
+
74
+ if ( ! Config . ready ) {
75
+ Config . setConnectionName ( connection . currentConnectionName ) ;
76
+ }
77
+
78
+ if ( ! this . installed ) {
79
+ this . installed = await this . isAlreadyInstalled ( ) ;
80
+ }
81
+
82
+ return this . installed ;
83
+ }
84
+
85
+ static async isAlreadyInstalled ( ) {
86
+ const instance = getInstance ( ) ;
87
+ const connection = instance . getConnection ( ) ;
88
+
70
89
const exists = await connection . sendCommand ( {
71
90
command : `ls ${ this . getComponentPath ( ) } `
72
91
} ) ;
73
92
74
- this . installed = ( exists . code === 0 ) ;
75
-
76
- return this . installed ;
93
+ return ( exists . code === 0 ) ;
77
94
}
78
95
79
96
/**
@@ -88,16 +105,18 @@ export class ServerComponent {
88
105
89
106
try {
90
107
const assetPath = path . join ( extensionPath , `dist` , SERVER_VERSION_FILE ) ;
91
- const assetExists = await exists ( assetPath ) ;
108
+ const assetExistsLocally = await exists ( assetPath ) ;
92
109
93
- ServerComponent . writeOutput ( JSON . stringify ( { assetPath, assetExists} ) ) ;
110
+ ServerComponent . writeOutput ( JSON . stringify ( { assetPath, assetExists : assetExistsLocally } ) ) ;
94
111
95
- if ( assetExists ) {
112
+ if ( assetExistsLocally ) {
96
113
const basename = SERVER_VERSION_FILE ;
97
114
const lastInstalledName = Config . getServerComponentName ( ) ;
98
115
99
116
ServerComponent . writeOutput ( JSON . stringify ( { basename, lastInstalledName} ) ) ;
100
117
118
+ await this . initialise ( ) ;
119
+
101
120
if ( lastInstalledName !== basename || this . installed === false ) {
102
121
// This means we're currently running a different version,
103
122
// or maybe not at all (currentlyInstalled can be undefined)
0 commit comments