Skip to content

Commit fff9b19

Browse files
catullBrocco
authored andcommitted
fix(@angular/cli): ng completion inside of ng app folders warns but does not produce output
If an ng app was created with an older version of ng CLI, while the global ng CLI is more recent, one cannot perform ng completion INSIDE that app folder. This is due to the warning being written to stdout, which if appended to ~/.bashrc causes the shell to fail to process the English text as commands. The solution is to display the warning to stderr without producing the completion output. In good Unix style, a non-zero status code must returned. This PR fixes #6343. The PR introduces a breaking change: - the warning is written to stderr - - no output is produced - different status code returned
1 parent eb4dc22 commit fff9b19

File tree

1 file changed

+15
-7
lines changed
  • packages/@angular/cli/bin

1 file changed

+15
-7
lines changed

packages/@angular/cli/bin/ng

+15-7
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,21 @@ resolve('@angular/cli', { basedir: process.cwd() },
155155
}
156156

157157
if (shouldWarn && CliConfig.fromGlobal().get('warnings.versionMismatch')) {
158-
// eslint-disable no-console
159-
console.log(yellow(stripIndents`
160-
Your global Angular CLI version (${globalVersion}) is greater than your local
161-
version (${localVersion}). The local Angular CLI version is used.
162-
163-
To disable this warning use "ng set --global warnings.versionMismatch=false".
164-
`));
158+
let warning = yellow(stripIndents`
159+
Your global Angular CLI version (${globalVersion}) is greater than your local
160+
version (${localVersion}). The local Angular CLI version is used.
161+
162+
To disable this warning use "ng set --global warnings.versionMismatch=false".
163+
`);
164+
// Don't show warning colorised on `ng completion`
165+
if (process.argv[2] !== 'completion') {
166+
// eslint-disable no-console
167+
console.log(warning);
168+
} else {
169+
// eslint-disable no-console
170+
console.error(warning);
171+
process.exit(1);
172+
}
165173
}
166174

167175
// No error implies a projectLocalCli, which will load whatever

0 commit comments

Comments
 (0)