Skip to content

Commit 67aa9c2

Browse files
clydinfilipesilva
authored andcommitted
refactor(@angular-devkit/schematics): allow use of a package manager's force option
This change allows consumers of the `NodeWorkflow` to configure the package installation task to use a package manager's `--force` option. This will be used by the `@angular/cli` update command when the update command's force option is used. This change is not intended to enable a schematic to adjust the force option. (cherry picked from commit f7dc97f)
1 parent 245fc50 commit 67aa9c2

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

goldens/public-api/angular_devkit/schematics/tools/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ export interface NodeWorkflowOptions {
138138
force?: boolean;
139139
optionTransforms?: OptionTransform<object, object>[];
140140
packageManager?: string;
141+
packageManagerForce?: boolean;
141142
packageRegistry?: string;
142143
registry?: schema.CoreSchemaRegistry;
143144
resolvePaths?: string[];

packages/angular_devkit/schematics/tasks/package-manager/executor.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ export default function (
104104
args.push(`--registry="${factoryOptions.registry}"`);
105105
}
106106

107+
if (factoryOptions.force) {
108+
args.push('--force');
109+
}
110+
107111
return new Observable((obs) => {
108112
const spinner = ora({
109113
text: `Installing packages (${taskPackageManagerName})...`,

packages/angular_devkit/schematics/tasks/package-manager/options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface NodePackageTaskFactoryOptions {
1313
packageManager?: string;
1414
allowPackageManagerOverride?: boolean;
1515
registry?: string;
16+
force?: boolean;
1617
}
1718

1819
export interface NodePackageTaskOptions {

packages/angular_devkit/schematics/tools/workflow/node-workflow.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface NodeWorkflowOptions {
1919
force?: boolean;
2020
dryRun?: boolean;
2121
packageManager?: string;
22+
packageManagerForce?: boolean;
2223
packageRegistry?: string;
2324
registry?: schema.CoreSchemaRegistry;
2425
resolvePaths?: string[];
@@ -60,6 +61,7 @@ export class NodeWorkflow extends workflow.BaseWorkflow {
6061
engineHost.registerTaskExecutor(BuiltinTaskExecutor.NodePackage, {
6162
allowPackageManagerOverride: true,
6263
packageManager: options.packageManager,
64+
force: options.packageManagerForce,
6365
rootDirectory: root && getSystemPath(root),
6466
registry: options.packageRegistry,
6567
});

0 commit comments

Comments
 (0)