Skip to content

Commit ddb92d8

Browse files
committed
fix(@angular/cli): improve --prod deprecation warning
Closes #20806
1 parent 438c6d9 commit ddb92d8

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

packages/angular/cli/models/architect-command.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface ArchitectCommandOptions extends BaseCommandOptions {
2323
}
2424

2525
export abstract class ArchitectCommand<
26-
T extends ArchitectCommandOptions = ArchitectCommandOptions
26+
T extends ArchitectCommandOptions = ArchitectCommandOptions,
2727
> extends Command<T> {
2828
protected _architect!: Architect;
2929
protected _architectHost!: WorkspaceNodeModulesArchitectHost;
@@ -238,7 +238,7 @@ export abstract class ArchitectCommand<
238238
}
239239

240240
await this.reportAnalytics([this.description.name], {
241-
...(((await this._architectHost.getOptionsForTarget(target)) as unknown) as T),
241+
...((await this._architectHost.getOptionsForTarget(target)) as unknown as T),
242242
...overrides,
243243
});
244244

@@ -344,11 +344,18 @@ export abstract class ArchitectCommand<
344344
project = commandOptions.project;
345345
target = this.target;
346346
if (commandOptions.prod) {
347-
// The --prod flag will always be the first configuration, available to be overwritten
348-
// by following configurations.
347+
const defaultConfig =
348+
project &&
349+
target &&
350+
this.workspace?.projects.get(project)?.targets.get(target)?.defaultConfiguration;
351+
349352
this.logger.warn(
350-
'Option "--prod" is deprecated: Use "--configuration production" instead.',
353+
defaultConfig === 'production'
354+
? 'Option "--prod" is deprecated: No need to use this option as this builder defaults to configuration "production".'
355+
: 'Option "--prod" is deprecated: Use "--configuration production" instead.',
351356
);
357+
// The --prod flag will always be the first configuration, available to be overwritten
358+
// by following configurations.
352359
configuration = 'production';
353360
}
354361
if (commandOptions.configuration) {

0 commit comments

Comments
 (0)