@@ -81,33 +81,37 @@ if (process.env['NG_CLI_PROFILING']) {
81
81
const projectLocalCli = require . resolve ( '@angular/cli' , { paths : [ process . cwd ( ) ] } ) ;
82
82
cli = await import ( projectLocalCli ) ;
83
83
84
- // This was run from a global, check local version.
85
- if ( await isWarningEnabled ( 'versionMismatch' ) ) {
86
- const globalVersion = new SemVer ( require ( '../package.json' ) . version ) ;
87
-
88
- // Older versions might not have the VERSION export
89
- let localVersion = cli . VERSION ?. full ;
90
- if ( ! localVersion ) {
91
- try {
92
- localVersion = require ( path . join ( path . dirname ( projectLocalCli ) , '../../package.json' ) )
93
- . version ;
94
- } catch ( error ) {
95
- // tslint:disable-next-line no-console
96
- console . error (
97
- 'Version mismatch check skipped. Unable to retrieve local version: ' + error ,
98
- ) ;
99
- }
100
- }
84
+ const globalVersion = new SemVer ( require ( '../package.json' ) . version ) ;
101
85
102
- let shouldWarn = false ;
86
+ // Older versions might not have the VERSION export
87
+ let localVersion = cli . VERSION ?. full ;
88
+ if ( ! localVersion ) {
103
89
try {
104
- shouldWarn = ! ! localVersion && globalVersion . compare ( localVersion ) > 0 ;
90
+ localVersion = require ( path . join ( path . dirname ( projectLocalCli ) , '../../package.json' ) )
91
+ . version ;
105
92
} catch ( error ) {
106
93
// tslint:disable-next-line no-console
107
- console . error ( 'Version mismatch check skipped. Unable to compare local version: ' + error ) ;
94
+ console . error (
95
+ 'Version mismatch check skipped. Unable to retrieve local version: ' + error ,
96
+ ) ;
108
97
}
98
+ }
99
+
100
+ let isGlobalGreater = false ;
101
+ try {
102
+ isGlobalGreater = ! ! localVersion && globalVersion . compare ( localVersion ) > 0 ;
103
+ } catch ( error ) {
104
+ // tslint:disable-next-line no-console
105
+ console . error ( 'Version mismatch check skipped. Unable to compare local version: ' + error ) ;
106
+ }
109
107
110
- if ( shouldWarn ) {
108
+ if ( isGlobalGreater ) {
109
+ // If using the update command and the global version is greater, use the newer update command
110
+ // This allows improvements in update to be used in older versions that do not have bootstrapping
111
+ if ( process . argv [ 2 ] === 'update' ) {
112
+ cli = await import ( './cli' ) ;
113
+ } else if ( await isWarningEnabled ( 'versionMismatch' ) ) {
114
+ // Otherwise, use local version and warn if global is newer than local
111
115
const warning =
112
116
`Your global Angular CLI version (${ globalVersion } ) is greater than your local ` +
113
117
`version (${ localVersion } ). The local Angular CLI version is used.\n\n` +
0 commit comments