Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/angular/cli/src/commands/update/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,11 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs

if (success) {
const { root: commandRoot } = this.context;
const force = await shouldForcePackageManager(packageManager, logger, options.verbose);
const ignorePeerDependencies = await shouldForcePackageManager(
packageManager,
logger,
options.verbose,
);
const tasks = new Listr([
{
title: 'Cleaning node modules directory',
Expand All @@ -545,15 +549,14 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
async task() {
try {
await packageManager.install({
force,
ignorePeerDependencies,
});
} catch (e) {
throw new CommandError('Unable to install packages');
}
},
},
]);

try {
await tasks.run();
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export interface PackageManagerDescriptor {
/** The flag to prevent lifecycle scripts from being executed. */
readonly ignoreScriptsFlag: string;

/** The flag to ignore peer dependency warnings/errors. */
readonly ignorePeerDependenciesFlag?: string;

/** A function that returns the arguments and environment variables to use a custom registry. */
readonly getRegistryOptions?: (registry: string) => {
args?: string[];
Expand Down Expand Up @@ -140,6 +143,7 @@ export const SUPPORTED_PACKAGE_MANAGERS = {
saveDevFlag: '--save-dev',
noLockfileFlag: '--no-package-lock',
ignoreScriptsFlag: '--ignore-scripts',
ignorePeerDependenciesFlag: '--legacy-peer-deps',
getRegistryOptions: (registry: string) => ({ args: ['--registry', registry] }),
versionCommand: ['--version'],
listDependenciesCommand: ['list', '--depth=0', '--json=true', '--all=true'],
Expand Down Expand Up @@ -215,6 +219,7 @@ export const SUPPORTED_PACKAGE_MANAGERS = {
saveDevFlag: '--save-dev',
noLockfileFlag: '--no-lockfile',
ignoreScriptsFlag: '--ignore-scripts',
ignorePeerDependenciesFlag: '--strict-peer-dependencies=false',
getRegistryOptions: (registry: string) => ({ args: ['--registry', registry] }),
versionCommand: ['--version'],
listDependenciesCommand: ['list', '--depth=0', '--json'],
Expand Down
2 changes: 2 additions & 0 deletions packages/angular/cli/src/package-managers/package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,13 @@ export class PackageManager {
force?: boolean;
registry?: string;
ignoreScripts?: boolean;
ignorePeerDependencies?: boolean;
} = { ignoreScripts: true },
): Promise<void> {
const flags = [
options.force ? this.descriptor.forceFlag : '',
options.ignoreScripts ? this.descriptor.ignoreScriptsFlag : '',
options.ignorePeerDependencies ? (this.descriptor.ignorePeerDependenciesFlag ?? '') : '',
].filter((flag) => flag);
const args = [...this.descriptor.installCommand, ...flags];

Expand Down