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.
This commit is contained in:
Charles Lyding 2022-05-27 11:13:19 -04:00 committed by Charles
parent 9ff2c55e85
commit 901f5dd7fc

View File

@ -98,7 +98,18 @@ export default function (
}
if (!options.allowScripts) {
args.push('--ignore-scripts');
// Yarn requires special handling since Yarn 2+ no longer has the `--ignore-scripts` flag
if (taskPackageManagerName === 'yarn') {
spawnOptions.env = {
...process.env,
// Supported with yarn 1
'npm_config_ignore_scripts': 'true',
// Supported with yarn 2+
'YARN_ENABLE_SCRIPTS': 'false',
};
} else {
args.push('--ignore-scripts');
}
}
if (factoryOptions.registry) {