Skip to content

Commit

Permalink
fix(@angular-devkit/schematics): support ignore scripts package insta…
Browse files Browse the repository at this point in the history
…lls 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)
  • Loading branch information
clydin committed May 27, 2022
1 parent 3471cd6 commit 48f9b79
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 48f9b79

Please sign in to comment.