diff --git a/common/changes/@microsoft/rush/jiawen-fix-color_2023-10-09-21-33.json b/common/changes/@microsoft/rush/jiawen-fix-color_2023-10-09-21-33.json new file mode 100644 index 00000000000..225e00ed3c8 --- /dev/null +++ b/common/changes/@microsoft/rush/jiawen-fix-color_2023-10-09-21-33.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Improve color logic when invoking package managers' install ", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file diff --git a/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts b/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts index 4141d156f97..18908a54d45 100644 --- a/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts +++ b/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts @@ -292,6 +292,9 @@ export class WorkspaceInstallManager extends BaseInstallManager { this.rushConfiguration, this.options ); + if (colors.enabled) { + packageManagerEnv.FORCE_COLOR = '1'; + } const commonNodeModulesFolder: string = path.join( this.rushConfiguration.commonTempFolder, @@ -318,7 +321,7 @@ export class WorkspaceInstallManager extends BaseInstallManager { // Run "npm install" in the common folder // To ensure that the output is always colored, set the option "--color=always", even when it's piped. // Without this argument, certain text that should be colored (such as red) will appear white. - const installArgs: string[] = ['install', '--color=always']; + const installArgs: string[] = ['install']; this.pushConfigurationArgs(installArgs, options); // eslint-disable-next-line no-console