Skip to content

Commit 9ff2c55

Browse files
committed
fix(@angular-devkit/schematics): support quiet package installs with Yarn 2+
Yarn 2 and higher no longer support the `--silent` flag. The `NodePackageInstallTask` will now spawn package managers with the stdout ignored when quiet mode is needed and only show stderr when the process exits unsuccessfully. This provides the necessary functionality for the task without relying on package manager options.
1 parent 5378557 commit 9ff2c55

File tree

1 file changed

+6
-9
lines changed
  • packages/angular_devkit/schematics/tasks/package-manager

1 file changed

+6
-9
lines changed

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

+6-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { TaskExecutor, UnsuccessfulWorkflowExecution } from '../../src';
1515
import { NodePackageTaskFactoryOptions, NodePackageTaskOptions } from './options';
1616

1717
interface PackageManagerProfile {
18-
quietArgument?: string;
1918
commands: {
2019
installAll?: string;
2120
installPackage: string;
@@ -24,7 +23,6 @@ interface PackageManagerProfile {
2423

2524
const packageManagers: { [name: string]: PackageManagerProfile } = {
2625
'npm': {
27-
quietArgument: '--quiet',
2826
commands: {
2927
installAll: 'install',
3028
installPackage: 'install',
@@ -37,13 +35,11 @@ const packageManagers: { [name: string]: PackageManagerProfile } = {
3735
},
3836
},
3937
'yarn': {
40-
quietArgument: '--silent',
4138
commands: {
4239
installPackage: 'add',
4340
},
4441
},
4542
'pnpm': {
46-
quietArgument: '--silent',
4743
commands: {
4844
installAll: 'install',
4945
installPackage: 'install',
@@ -81,10 +77,15 @@ export default function (
8177

8278
const bufferedOutput: { stream: NodeJS.WriteStream; data: Buffer }[] = [];
8379
const spawnOptions: SpawnOptions = {
84-
stdio: options.hideOutput ? 'pipe' : 'inherit',
8580
shell: true,
8681
cwd: path.join(rootDirectory, options.workingDirectory || ''),
8782
};
83+
if (options.hideOutput) {
84+
spawnOptions.stdio = options.quiet ? ['ignore', 'ignore', 'pipe'] : 'pipe';
85+
} else {
86+
spawnOptions.stdio = options.quiet ? ['ignore', 'ignore', 'inherit'] : 'inherit';
87+
}
88+
8889
const args: string[] = [];
8990

9091
if (options.packageName) {
@@ -96,10 +97,6 @@ export default function (
9697
args.push(taskPackageManagerProfile.commands.installAll);
9798
}
9899

99-
if (options.quiet && taskPackageManagerProfile.quietArgument) {
100-
args.push(taskPackageManagerProfile.quietArgument);
101-
}
102-
103100
if (!options.allowScripts) {
104101
args.push('--ignore-scripts');
105102
}

0 commit comments

Comments
 (0)