Skip to content

Commit 26f71ef

Browse files
committed
fixup! Add support for .env files.
1 parent cbfe523 commit 26f71ef

6 files changed

Lines changed: 17 additions & 3 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export class RushCommandLineParser extends CommandLineParser {
131131
});
132132

133133
if (EnvironmentConfiguration.hasBeenValidated) {
134-
terminal.writeWarningLine(
134+
throw new Error(
135135
`The ${EnvironmentConfiguration.name} was initialized before .env files were loaded. Rush environment ` +
136136
'variables may have unexpected values.'
137137
);

libraries/rush-lib/src/cli/actions/test/AddAction.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33

44
import '../../test/mockRushCommandLineParser';
55

6+
import { LockFile } from '@rushstack/node-core-library';
7+
68
import { PackageJsonUpdater } from '../../../logic/PackageJsonUpdater';
79
import type { IPackageJsonUpdaterRushAddOptions } from '../../../logic/PackageJsonUpdaterTypes';
810
import { RushCommandLineParser } from '../../RushCommandLineParser';
911
import { AddAction } from '../AddAction';
10-
import { LockFile } from '@rushstack/node-core-library';
12+
import { EnvironmentConfiguration } from '../../../api/EnvironmentConfiguration';
1113

1214
describe(AddAction.name, () => {
1315
describe('basic "rush add" tests', () => {
@@ -32,6 +34,7 @@ describe(AddAction.name, () => {
3234
jest.clearAllMocks();
3335
process.exitCode = oldExitCode;
3436
process.argv = oldArgs;
37+
EnvironmentConfiguration.reset();
3538
});
3639

3740
describe("'add' action", () => {

libraries/rush-lib/src/cli/actions/test/RemoveAction.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33

44
import '../../test/mockRushCommandLineParser';
55

6+
import { LockFile } from '@rushstack/node-core-library';
7+
68
import { PackageJsonUpdater } from '../../../logic/PackageJsonUpdater';
79
import type { IPackageJsonUpdaterRushRemoveOptions } from '../../../logic/PackageJsonUpdaterTypes';
810
import { RushCommandLineParser } from '../../RushCommandLineParser';
911
import { RemoveAction } from '../RemoveAction';
1012
import { VersionMismatchFinderProject } from '../../../logic/versionMismatch/VersionMismatchFinderProject';
1113
import { DependencyType } from '../../../api/PackageJsonEditor';
12-
import { LockFile } from '@rushstack/node-core-library';
14+
import { EnvironmentConfiguration } from '../../../api/EnvironmentConfiguration';
1315

1416
describe(RemoveAction.name, () => {
1517
describe('basic "rush remove" tests', () => {
@@ -36,6 +38,7 @@ describe(RemoveAction.name, () => {
3638
jest.clearAllMocks();
3739
process.exitCode = oldExitCode;
3840
process.argv = oldArgs;
41+
EnvironmentConfiguration.reset();
3942
});
4043

4144
describe("'remove' action", () => {

libraries/rush-lib/src/cli/test/CommandLineHelp.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import { AnsiEscape } from '@rushstack/terminal';
55

66
import { RushCommandLineParser } from '../RushCommandLineParser';
7+
import { EnvironmentConfiguration } from '../../api/EnvironmentConfiguration';
78

89
describe('CommandLineHelp', () => {
910
let oldCwd: string | undefined;
@@ -33,6 +34,8 @@ describe('CommandLineHelp', () => {
3334
if (oldCwd) {
3435
process.chdir(oldCwd);
3536
}
37+
38+
EnvironmentConfiguration.reset();
3639
});
3740

3841
it('prints the global help', () => {

libraries/rush-lib/src/cli/test/RushCommandLineParser.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { FileSystem, JsonFile, Path } from '@rushstack/node-core-library';
2727
import { Autoinstaller } from '../../logic/Autoinstaller';
2828
import type { ITelemetryData } from '../../logic/Telemetry';
2929
import { getCommandLineParserInstanceAsync } from './TestUtils';
30+
import { EnvironmentConfiguration } from '../../api/EnvironmentConfiguration';
3031

3132
function pathEquals(actual: string, expected: string): void {
3233
expect(Path.convertToSlashes(actual)).toEqual(Path.convertToSlashes(expected));
@@ -40,6 +41,7 @@ describe('RushCommandLineParser', () => {
4041
describe('execute', () => {
4142
afterEach(() => {
4243
jest.clearAllMocks();
44+
EnvironmentConfiguration.reset();
4345
});
4446

4547
describe('in basic repo', () => {

libraries/rush-lib/src/cli/test/RushPluginCommandLineParameters.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import path from 'path';
77
import { FileSystem, LockFile } from '@rushstack/node-core-library';
88
import { RushCommandLineParser } from '../RushCommandLineParser';
99
import { Autoinstaller } from '../../logic/Autoinstaller';
10+
import { EnvironmentConfiguration } from '../../api/EnvironmentConfiguration';
1011

1112
describe('PluginCommandLineParameters', () => {
1213
let originCWD: string | undefined;
@@ -61,6 +62,8 @@ describe('PluginCommandLineParameters', () => {
6162
originCWD = undefined;
6263
process.argv = _argv;
6364
}
65+
66+
EnvironmentConfiguration.reset();
6467
});
6568

6669
afterAll(() => {

0 commit comments

Comments
 (0)