File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed
packages/@vue/cli/lib/util Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -26,8 +26,7 @@ async function getInstallationCommand () {
2626}
2727
2828exports . generateTitle = async function ( checkUpdate ) {
29- const { current, latest } = await getVersions ( )
30-
29+ const { current, latest, error } = await getVersions ( )
3130 let title = chalk . bold . blue ( `Vue CLI v${ current } ` )
3231
3332 if ( process . env . VUE_CLI_TEST ) {
@@ -36,7 +35,12 @@ exports.generateTitle = async function (checkUpdate) {
3635 if ( process . env . VUE_CLI_DEBUG ) {
3736 title += ' ' + chalk . magenta . bold ( 'DEBUG' )
3837 }
39- if ( checkUpdate && semver . gt ( latest , current ) ) {
38+
39+ if ( error ) {
40+ title += '\n' + chalk . red ( 'Failed to check for updates' )
41+ }
42+
43+ if ( checkUpdate && ! error && semver . gt ( latest , current ) ) {
4044 if ( process . env . VUE_CLI_API_MODE ) {
4145 title += chalk . green ( ` 🌟️ New version available: ${ latest } ` )
4246 } else {
Original file line number Diff line number Diff line change @@ -26,20 +26,28 @@ module.exports = async function getVersions () {
2626 const cached = latestVersion
2727 const daysPassed = ( Date . now ( ) - lastChecked ) / ( 60 * 60 * 1000 * 24 )
2828
29+ let error
2930 if ( daysPassed > 1 ) {
3031 // if we haven't check for a new version in a day, wait for the check
3132 // before proceeding
32- latest = await getAndCacheLatestVersion ( cached , includePrerelease )
33+ try {
34+ latest = await getAndCacheLatestVersion ( cached , includePrerelease )
35+ } catch ( e ) {
36+ latest = cached
37+ error = e
38+ }
3339 } else {
3440 // Otherwise, do a check in the background. If the result was updated,
3541 // it will be used for the next 24 hours.
36- getAndCacheLatestVersion ( cached , includePrerelease )
42+ // don't throw to interrupt the user if the background check failed
43+ getAndCacheLatestVersion ( cached , includePrerelease ) . catch ( ( ) => { } )
3744 latest = cached
3845 }
3946
4047 return ( sessionCached = {
4148 current : local ,
42- latest
49+ latest,
50+ error
4351 } )
4452}
4553
You can’t perform that action at this time.
0 commit comments