@@ -94,10 +94,10 @@ export class UpdatePowerShell {
9494 return true ;
9595 }
9696
97- private async getRemoteVersion ( url : string ) : Promise < string > {
97+ private async getRemoteVersion ( url : string ) : Promise < string | undefined > {
9898 const response = await fetch ( url ) ;
9999 if ( ! response . ok ) {
100- throw new Error ( "Failed to get remote version!" ) ;
100+ return undefined ;
101101 }
102102 // Looks like:
103103 // {
@@ -119,17 +119,26 @@ export class UpdatePowerShell {
119119 const tags : string [ ] = [ ] ;
120120 if ( process . env . POWERSHELL_UPDATECHECK ?. toLowerCase ( ) === "lts" ) {
121121 // 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+ }
124127 } else {
125128 // 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+ }
128134
129135 // Also check for a preview update.
130136 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+ }
133142 }
134143 }
135144
@@ -147,7 +156,7 @@ export class UpdatePowerShell {
147156 try {
148157 const tag = await this . maybeGetNewRelease ( ) ;
149158 if ( tag ) {
150- return await this . installUpdate ( tag ) ;
159+ return await this . promptToUpdate ( tag ) ;
151160 }
152161 } catch ( err ) {
153162 // Best effort. This probably failed to fetch the data from GitHub.
@@ -160,13 +169,13 @@ export class UpdatePowerShell {
160169 await vscode . env . openExternal ( url ) ;
161170 }
162171
163- private async installUpdate ( tag : string ) : Promise < void > {
172+ private async promptToUpdate ( tag : string ) : Promise < void > {
164173 const releaseVersion = new SemVer ( tag ) ;
165174 this . logger . write ( `Prompting to update PowerShell v${ this . localVersion . version } to v${ releaseVersion . version } .` ) ;
166175 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?` ,
170179 ...UpdatePowerShell . promptOptions ) ;
171180
172181 // If the user cancels the notification.
0 commit comments