Skip to content

Commit 4434e5f

Browse files
committed
Allow ng completion from everywhere. If called inside an ng app folder make it a shell comment.
1 parent 22b25e8 commit 4434e5f

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

packages/@angular/cli/bin/ng

Lines changed: 11 additions & 3 deletions
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`
158+
let warning = stripIndents`
160159
Your global Angular CLI version (${globalVersion}) is greater than your local
161160
version (${localVersion}). The local Angular CLI version is used.
162161
163162
To disable this warning use "ng set --global warnings.versionMismatch=false".
164-
`));
163+
`;
164+
// Don't show warning colorised on `ng completion`
165+
if (process.argv[2] !== 'completion') {
166+
// eslint-disable no-console
167+
console.log(yellow(warning));
168+
} else {
169+
warning = warning.replace(/^/gm, '# ');
170+
// eslint-disable no-console
171+
console.log(warning);
172+
}
165173
}
166174

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

packages/@angular/cli/commands/completion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const optsNg: string[] = [];
4343
const CompletionCommand = Command.extend({
4444
name: 'completion',
4545
description: 'Adds autocomplete functionality to `ng` commands and subcommands.',
46-
works: 'outsideProject',
46+
works: 'everywhere',
4747
availableOptions: [
4848
{
4949
name: 'all',

0 commit comments

Comments
 (0)