Skip to content

Commit

Permalink
fix(@angular/cli): improve --prod deprecation warning
Browse files Browse the repository at this point in the history
Closes  #20806

(cherry picked from commit ddb92d8)
  • Loading branch information
alan-agius4 committed May 17, 2021
1 parent 7718efe commit effc961
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/angular/cli/models/architect-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface ArchitectCommandOptions extends BaseCommandOptions {
}

export abstract class ArchitectCommand<
T extends ArchitectCommandOptions = ArchitectCommandOptions
T extends ArchitectCommandOptions = ArchitectCommandOptions,
> extends Command<T> {
protected _architect!: Architect;
protected _architectHost!: WorkspaceNodeModulesArchitectHost;
Expand Down Expand Up @@ -238,7 +238,7 @@ export abstract class ArchitectCommand<
}

await this.reportAnalytics([this.description.name], {
...(((await this._architectHost.getOptionsForTarget(target)) as unknown) as T),
...((await this._architectHost.getOptionsForTarget(target)) as unknown as T),
...overrides,
});

Expand Down Expand Up @@ -344,11 +344,18 @@ export abstract class ArchitectCommand<
project = commandOptions.project;
target = this.target;
if (commandOptions.prod) {
// The --prod flag will always be the first configuration, available to be overwritten
// by following configurations.
const defaultConfig =
project &&
target &&
this.workspace?.projects.get(project)?.targets.get(target)?.defaultConfiguration;

this.logger.warn(
'Option "--prod" is deprecated: Use "--configuration production" instead.',
defaultConfig === 'production'
? 'Option "--prod" is deprecated: No need to use this option as this builder defaults to configuration "production".'
: 'Option "--prod" is deprecated: Use "--configuration production" instead.',
);
// The --prod flag will always be the first configuration, available to be overwritten
// by following configurations.
configuration = 'production';
}
if (commandOptions.configuration) {
Expand Down

0 comments on commit effc961

Please sign in to comment.