Skip to content

Commit bab5165

Browse files
authored
fix, hide pnpm output when a command is running with --json (#9275)
1 parent 2516a5e commit bab5165

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

scopes/dependencies/dependency-resolver/dependency-installer.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ export class DependencyInstaller {
102102

103103
private preferOffline?: boolean,
104104

105-
private installingContext: DepInstallerContext = {},
105+
private installingContext: DepInstallerContext = {}
106106
) {}
107107

108108
async install(
109109
rootDir: string | undefined,
110110
rootPolicy: WorkspacePolicy,
111111
componentDirectoryMap: ComponentMap<string>,
112112
options: InstallOptions = DEFAULT_INSTALL_OPTIONS,
113-
packageManagerOptions: PackageManagerInstallOptions = DEFAULT_PM_INSTALL_OPTIONS,
113+
packageManagerOptions: PackageManagerInstallOptions = DEFAULT_PM_INSTALL_OPTIONS
114114
) {
115115
const finalRootDir = rootDir ?? this.rootDir;
116116
if (!finalRootDir) {
@@ -131,7 +131,7 @@ export class DependencyInstaller {
131131
rootPolicy,
132132
componentDirectoryMap,
133133
options,
134-
packageManagerOptions,
134+
packageManagerOptions
135135
);
136136
}
137137

@@ -141,7 +141,7 @@ export class DependencyInstaller {
141141
rootPolicy: WorkspacePolicy,
142142
componentDirectoryMap: ComponentMap<string>,
143143
options: InstallOptions = DEFAULT_INSTALL_OPTIONS,
144-
packageManagerOptions: PackageManagerInstallOptions = DEFAULT_PM_INSTALL_OPTIONS,
144+
packageManagerOptions: PackageManagerInstallOptions = DEFAULT_PM_INSTALL_OPTIONS
145145
): Promise<{ dependenciesChanged: boolean }> {
146146
const args = {
147147
componentDirectoryMap,
@@ -159,7 +159,7 @@ export class DependencyInstaller {
159159
if (options.linkedDependencies) {
160160
manifests = JSON.parse(JSON.stringify(manifests));
161161
const linkedDependencies = JSON.parse(
162-
JSON.stringify(options.linkedDependencies),
162+
JSON.stringify(options.linkedDependencies)
163163
) as typeof options.linkedDependencies;
164164
if (linkedDependencies[finalRootDir]) {
165165
const directDeps = new Set<string>();
@@ -188,7 +188,9 @@ export class DependencyInstaller {
188188
};
189189
});
190190
}
191-
const hidePackageManagerOutput = !!(this.installingContext.inCapsule && process.env.VERBOSE_PM_OUTPUT !== 'true');
191+
const isJsonCmd = process.argv.includes('--json') || process.argv.includes('-j');
192+
const hidePackageManagerOutput =
193+
Boolean(this.installingContext.inCapsule && process.env.VERBOSE_PM_OUTPUT !== 'true') || isJsonCmd;
192194

193195
// Make sure to take other default if passed options with only one option
194196
const calculatedPmOpts = {
@@ -252,7 +254,7 @@ export class DependencyInstaller {
252254
manifests,
253255
componentDirectoryMap,
254256
},
255-
calculatedPmOpts,
257+
calculatedPmOpts
256258
);
257259
if (!hidePackageManagerOutput) {
258260
this.logger.consoleSuccess(`done ${message}`, startTime);
@@ -303,7 +305,7 @@ export class DependencyInstaller {
303305
rootDir,
304306
componentDirectoryMap.components,
305307
options,
306-
this.installingContext,
308+
this.installingContext
307309
);
308310
const manifests: Record<string, ProjectManifest> = componentDirectoryMap
309311
.toArray()
@@ -335,7 +337,7 @@ export class DependencyInstaller {
335337
private async runPrePostSubscribers(
336338
subscribers: PreInstallSubscriberList | PostInstallSubscriberList = [],
337339
type: 'pre' | 'post',
338-
args: InstallArgs,
340+
args: InstallArgs
339341
): Promise<void> {
340342
const message = this.installingContext?.inCapsule
341343
? `(capsule) running ${type} install subscribers in root dir ${this.rootDir}`

0 commit comments

Comments
 (0)