Skip to content

Commit 901f5dd

Browse files
committed
fix(@angular-devkit/schematics): support ignore scripts package installs with Yarn 2+
Yarn 2 and higher no longer support the `--ignore-scripts` flag. The `NodePackageInstallTask` will now spawn Yarn with environment variables to ignore scripts instead of the commandline option. Other package managers remain unchanged. This provides the necessary functionality for the task without relying on Yarn commandline options.
1 parent 9ff2c55 commit 901f5dd

File tree

1 file changed

+12
-1
lines changed
  • packages/angular_devkit/schematics/tasks/package-manager

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,18 @@ export default function (
9898
}
9999

100100
if (!options.allowScripts) {
101-
args.push('--ignore-scripts');
101+
// Yarn requires special handling since Yarn 2+ no longer has the `--ignore-scripts` flag
102+
if (taskPackageManagerName === 'yarn') {
103+
spawnOptions.env = {
104+
...process.env,
105+
// Supported with yarn 1
106+
'npm_config_ignore_scripts': 'true',
107+
// Supported with yarn 2+
108+
'YARN_ENABLE_SCRIPTS': 'false',
109+
};
110+
} else {
111+
args.push('--ignore-scripts');
112+
}
102113
}
103114

104115
if (factoryOptions.registry) {

0 commit comments

Comments
 (0)