@@ -94,10 +94,10 @@ export class UpdatePowerShell {
94
94
return true ;
95
95
}
96
96
97
- private async getRemoteVersion ( url : string ) : Promise < string > {
97
+ private async getRemoteVersion ( url : string ) : Promise < string | undefined > {
98
98
const response = await fetch ( url ) ;
99
99
if ( ! response . ok ) {
100
- throw new Error ( "Failed to get remote version!" ) ;
100
+ return undefined ;
101
101
}
102
102
// Looks like:
103
103
// {
@@ -119,17 +119,26 @@ export class UpdatePowerShell {
119
119
const tags : string [ ] = [ ] ;
120
120
if ( process . env . POWERSHELL_UPDATECHECK ?. toLowerCase ( ) === "lts" ) {
121
121
// Only check for update to LTS.
122
- this . logger . writeDiagnostic ( "Checking for LTS update." ) ;
123
- tags . push ( await this . getRemoteVersion ( UpdatePowerShell . LTSBuildInfoURL ) ) ;
122
+ this . logger . writeVerbose ( "Checking for LTS update..." ) ;
123
+ const tag = await this . getRemoteVersion ( UpdatePowerShell . LTSBuildInfoURL ) ;
124
+ if ( tag != undefined ) {
125
+ tags . push ( tag ) ;
126
+ }
124
127
} else {
125
128
// Check for update to stable.
126
- this . logger . writeDiagnostic ( "Checking for stable update." ) ;
127
- tags . push ( await this . getRemoteVersion ( UpdatePowerShell . StableBuildInfoURL ) ) ;
129
+ this . logger . writeVerbose ( "Checking for stable update..." ) ;
130
+ const tag = await this . getRemoteVersion ( UpdatePowerShell . StableBuildInfoURL ) ;
131
+ if ( tag != undefined ) {
132
+ tags . push ( tag ) ;
133
+ }
128
134
129
135
// Also check for a preview update.
130
136
if ( this . localVersion . prerelease . length > 0 ) {
131
- this . logger . writeDiagnostic ( "Checking for preview update." ) ;
132
- tags . push ( await this . getRemoteVersion ( UpdatePowerShell . PreviewBuildInfoURL ) ) ;
137
+ this . logger . writeVerbose ( "Checking for preview update..." ) ;
138
+ const tag = await this . getRemoteVersion ( UpdatePowerShell . PreviewBuildInfoURL ) ;
139
+ if ( tag != undefined ) {
140
+ tags . push ( tag ) ;
141
+ }
133
142
}
134
143
}
135
144
@@ -147,7 +156,7 @@ export class UpdatePowerShell {
147
156
try {
148
157
const tag = await this . maybeGetNewRelease ( ) ;
149
158
if ( tag ) {
150
- return await this . installUpdate ( tag ) ;
159
+ return await this . promptToUpdate ( tag ) ;
151
160
}
152
161
} catch ( err ) {
153
162
// Best effort. This probably failed to fetch the data from GitHub.
@@ -160,13 +169,13 @@ export class UpdatePowerShell {
160
169
await vscode . env . openExternal ( url ) ;
161
170
}
162
171
163
- private async installUpdate ( tag : string ) : Promise < void > {
172
+ private async promptToUpdate ( tag : string ) : Promise < void > {
164
173
const releaseVersion = new SemVer ( tag ) ;
165
174
this . logger . write ( `Prompting to update PowerShell v${ this . localVersion . version } to v${ releaseVersion . version } .` ) ;
166
175
const result = await vscode . window . showInformationMessage (
167
- `You have an old version of PowerShell ( ${ this . localVersion . version } ) .
168
- The current latest release is ${ releaseVersion . version } .
169
- Would you like to open the GitHub release in your browser?` ,
176
+ `PowerShell v ${ this . localVersion . version } is out-of-date .
177
+ The latest version is v ${ releaseVersion . version } .
178
+ Would you like to open the GitHub release in your browser?` ,
170
179
...UpdatePowerShell . promptOptions ) ;
171
180
172
181
// If the user cancels the notification.
0 commit comments