Skip to content

Commit c5a1a45

Browse files
committed
fix(@angular/cli): eliminate prompts during ng version command
This update removes the analytics and completion prompts that appear when executing the `ng version` command, ensuring a smoother and uninterrupted user experience. Closes #27668
1 parent 0a69322 commit c5a1a45

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

packages/angular/cli/src/command-builder/command-module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ export abstract class CommandModule<T extends {} = {}> implements CommandModuleI
176176

177177
const userId = await getAnalyticsUserId(
178178
this.context,
179-
// Don't prompt for `ng update` and `ng analytics` commands.
180-
['update', 'analytics'].includes(this.commandName),
179+
// Don't prompt on `ng update`, 'ng version' or `ng analytics`.
180+
['version', 'update', 'analytics'].includes(this.commandName),
181181
);
182182

183183
return userId ? new AnalyticsCollector(this.context, userId) : undefined;

packages/angular/cli/src/utilities/completion.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ async function shouldPromptForAutocompletionSetup(
130130
return forceAutocomplete;
131131
}
132132

133-
// Don't prompt on `ng update` or `ng completion`.
134-
if (command === 'update' || command === 'completion') {
133+
// Don't prompt on `ng update`, 'ng version' or `ng completion`.
134+
if (['version', 'update', 'completion'].includes(command)) {
135135
return false;
136136
}
137137

tests/legacy-cli/e2e/tests/commands/analytics/ask-analytics-command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default async function () {
88
await mockHome(async () => {
99
const { stdout } = await execWithEnv(
1010
'ng',
11-
['version'],
11+
['config'],
1212
{
1313
...process.env,
1414
NG_FORCE_TTY: '1',
@@ -24,7 +24,7 @@ export default async function () {
2424

2525
// CLI should skip analytics prompt with `NG_CLI_ANALYTICS=false`.
2626
await mockHome(async () => {
27-
const { stdout } = await execWithEnv('ng', ['version'], {
27+
const { stdout } = await execWithEnv('ng', ['config'], {
2828
...process.env,
2929
NG_FORCE_TTY: '1',
3030
NG_CLI_ANALYTICS: 'false',

0 commit comments

Comments
 (0)