Skip to content

Commit 02fbdc2

Browse files
authored
Merge pull request #2705 from EmmanuelOluyomi/AllowWarnings
[rush-lib] Add environment variable to override allowWarningsInSuccessfulBuild setting
2 parents 77e416e + 4d83975 commit 02fbdc2

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

apps/rush-lib/src/api/EnvironmentConfiguration.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ export const enum EnvironmentVariableNames {
4040
*/
4141
RUSH_ALLOW_UNSUPPORTED_NODEJS = 'RUSH_ALLOW_UNSUPPORTED_NODEJS',
4242

43+
/**
44+
* Setting this environment variable overrides the value of `allowWarningsInSuccessfulBuild`
45+
* in the `command-line.json` configuration file. Specify `1` to allow warnings in a successful build,
46+
* or `0` to disallow them. (See the comments in the command-line.json file for more information).
47+
*/
48+
RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD = 'RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD',
49+
4350
/**
4451
* This variable selects a specific installation variant for Rush to use when installing
4552
* and linking package dependencies.
@@ -156,6 +163,8 @@ export class EnvironmentConfiguration {
156163

157164
private static _allowUnsupportedNodeVersion: boolean = false;
158165

166+
private static _allowWarningsInSuccessfulBuild: boolean = false;
167+
159168
private static _pnpmStorePathOverride: string | undefined;
160169

161170
private static _rushGlobalFolderOverride: string | undefined;
@@ -197,6 +206,16 @@ export class EnvironmentConfiguration {
197206
return EnvironmentConfiguration._allowUnsupportedNodeVersion;
198207
}
199208

209+
/**
210+
* Setting this environment variable overrides the value of `allowWarningsInSuccessfulBuild`
211+
* in the `command-line.json` configuration file. Specify `1` to allow warnings in a successful build,
212+
* or `0` to disallow them. (See the comments in the command-line.json file for more information).
213+
*/
214+
public static get allowWarningsInSuccessfulBuild(): boolean {
215+
EnvironmentConfiguration._ensureInitialized();
216+
return EnvironmentConfiguration._allowWarningsInSuccessfulBuild;
217+
}
218+
200219
/**
201220
* An override for the PNPM store path, if `pnpmStore` configuration is set to 'path'
202221
* See {@link EnvironmentVariableNames.RUSH_PNPM_STORE_PATH}
@@ -312,6 +331,15 @@ export class EnvironmentConfiguration {
312331
break;
313332
}
314333

334+
case EnvironmentVariableNames.RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD: {
335+
EnvironmentConfiguration._allowWarningsInSuccessfulBuild =
336+
EnvironmentConfiguration.parseBooleanEnvironmentVariable(
337+
EnvironmentVariableNames.RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD,
338+
value
339+
) ?? false;
340+
break;
341+
}
342+
315343
case EnvironmentVariableNames.RUSH_PNPM_STORE_PATH: {
316344
EnvironmentConfiguration._pnpmStorePathOverride =
317345
value && !options.doNotNormalizePaths

apps/rush-lib/src/cli/RushCommandLineParser.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { Telemetry } from '../logic/Telemetry';
4242
import { RushGlobalFolder } from '../api/RushGlobalFolder';
4343
import { NodeJsCompatibility } from '../logic/NodeJsCompatibility';
4444
import { SetupAction } from './actions/SetupAction';
45+
import { EnvironmentConfiguration } from '../api/EnvironmentConfiguration';
4546

4647
/**
4748
* Options for `RushCommandLineParser`.
@@ -248,6 +249,9 @@ export class RushCommandLineParser extends CommandLineParser {
248249

249250
this._validateCommandLineConfigCommand(command);
250251

252+
const overrideAllowWarnings: boolean =
253+
this.rushConfiguration && EnvironmentConfiguration.allowWarningsInSuccessfulBuild;
254+
251255
switch (command.commandKind) {
252256
case RushConstants.bulkCommandKind:
253257
this.addAction(
@@ -269,7 +273,7 @@ export class RushCommandLineParser extends CommandLineParser {
269273
ignoreMissingScript: command.ignoreMissingScript || false,
270274
ignoreDependencyOrder: command.ignoreDependencyOrder || false,
271275
incremental: command.incremental || false,
272-
allowWarningsInSuccessfulBuild: !!command.allowWarningsInSuccessfulBuild,
276+
allowWarningsInSuccessfulBuild: overrideAllowWarnings || !!command.allowWarningsInSuccessfulBuild,
273277

274278
watchForChanges: command.watchForChanges || false,
275279
disableBuildCache: command.disableBuildCache || false
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/rush",
5+
"comment": "Add RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD environment variable",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/rush",
10+
"email": "EmmanuelOluyomi@users.noreply.github.com"
11+
}

common/reviews/api/rush-lib.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export const enum DependencyType {
9696
export const enum EnvironmentVariableNames {
9797
RUSH_ABSOLUTE_SYMLINKS = "RUSH_ABSOLUTE_SYMLINKS",
9898
RUSH_ALLOW_UNSUPPORTED_NODEJS = "RUSH_ALLOW_UNSUPPORTED_NODEJS",
99+
RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD = "RUSH_ALLOW_WARNINGS_IN_SUCCESSFUL_BUILD",
99100
RUSH_BUILD_CACHE_CREDENTIAL = "RUSH_BUILD_CACHE_CREDENTIAL",
100101
RUSH_BUILD_CACHE_ENABLED = "RUSH_BUILD_CACHE_ENABLED",
101102
RUSH_BUILD_CACHE_WRITE_ALLOWED = "RUSH_BUILD_CACHE_WRITE_ALLOWED",

0 commit comments

Comments
 (0)