Skip to content

Commit 48f9b79

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. (cherry picked from commit 901f5dd)
1 parent 3471cd6 commit 48f9b79

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

+12-1
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)