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,17 +26,21 @@ async function getInstallationCommand () {
26
26
}
27
27
28
28
exports . generateTitle = async function ( checkUpdate ) {
29
- const { current, latest } = await getVersions ( )
30
-
29
+ const { current, latest, error } = await getVersions ( )
31
30
let title = chalk . bold . blue ( `Vue CLI v${ current } ` )
32
31
32
+ if ( error ) {
33
+ title += '\n' + chalk . red ( 'Failed to check for updates' )
34
+ }
35
+
33
36
if ( process . env . VUE_CLI_TEST ) {
34
37
title += ' ' + chalk . blue . bold ( 'TEST' )
35
38
}
36
39
if ( process . env . VUE_CLI_DEBUG ) {
37
40
title += ' ' + chalk . magenta . bold ( 'DEBUG' )
38
41
}
39
- if ( checkUpdate && semver . gt ( latest , current ) ) {
42
+
43
+ if ( checkUpdate && ! error && semver . gt ( latest , current ) ) {
40
44
if ( process . env . VUE_CLI_API_MODE ) {
41
45
title += chalk . green ( ` 🌟️ New version available: ${ latest } ` )
42
46
} else {
Original file line number Diff line number Diff line change @@ -26,20 +26,28 @@ module.exports = async function getVersions () {
26
26
const cached = latestVersion
27
27
const daysPassed = ( Date . now ( ) - lastChecked ) / ( 60 * 60 * 1000 * 24 )
28
28
29
+ let error
29
30
if ( daysPassed > 1 ) {
30
31
// if we haven't check for a new version in a day, wait for the check
31
32
// 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
+ }
33
39
} else {
34
40
// Otherwise, do a check in the background. If the result was updated,
35
41
// 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 ( ( ) => { } )
37
44
latest = cached
38
45
}
39
46
40
47
return ( sessionCached = {
41
48
current : local ,
42
- latest
49
+ latest,
50
+ error
43
51
} )
44
52
}
45
53
You can’t perform that action at this time.
0 commit comments