1- import { InternalError } from '@rushstack/node-core-library' ;
21// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
32// See LICENSE in the project root for license information.
43
@@ -155,7 +154,7 @@ export const enum EnvironmentVariableNames {
155154 * Initialize will throw if any unknown parameters are present.
156155 */
157156export class EnvironmentConfiguration {
158- private static _hasBeenInitialized : boolean = false ;
157+ private static _hasBeenValidated : boolean = false ;
159158
160159 private static _rushTempFolderOverride : string | undefined ;
161160
@@ -181,7 +180,7 @@ export class EnvironmentConfiguration {
181180 * An override for the common/temp folder path.
182181 */
183182 public static get rushTempFolderOverride ( ) : string | undefined {
184- EnvironmentConfiguration . _ensureInitialized ( ) ;
183+ EnvironmentConfiguration . _ensureValidated ( ) ;
185184 return EnvironmentConfiguration . _rushTempFolderOverride ;
186185 }
187186
@@ -190,7 +189,7 @@ export class EnvironmentConfiguration {
190189 * See {@link EnvironmentVariableNames.RUSH_ABSOLUTE_SYMLINKS}
191190 */
192191 public static get absoluteSymlinks ( ) : boolean {
193- EnvironmentConfiguration . _ensureInitialized ( ) ;
192+ EnvironmentConfiguration . _ensureValidated ( ) ;
194193 return EnvironmentConfiguration . _absoluteSymlinks ;
195194 }
196195
@@ -202,7 +201,7 @@ export class EnvironmentConfiguration {
202201 * See {@link EnvironmentVariableNames.RUSH_ALLOW_UNSUPPORTED_NODEJS}.
203202 */
204203 public static get allowUnsupportedNodeVersion ( ) : boolean {
205- EnvironmentConfiguration . _ensureInitialized ( ) ;
204+ EnvironmentConfiguration . _ensureValidated ( ) ;
206205 return EnvironmentConfiguration . _allowUnsupportedNodeVersion ;
207206 }
208207
@@ -212,7 +211,7 @@ export class EnvironmentConfiguration {
212211 * or `0` to disallow them. (See the comments in the command-line.json file for more information).
213212 */
214213 public static get allowWarningsInSuccessfulBuild ( ) : boolean {
215- EnvironmentConfiguration . _ensureInitialized ( ) ;
214+ EnvironmentConfiguration . _ensureValidated ( ) ;
216215 return EnvironmentConfiguration . _allowWarningsInSuccessfulBuild ;
217216 }
218217
@@ -221,7 +220,7 @@ export class EnvironmentConfiguration {
221220 * See {@link EnvironmentVariableNames.RUSH_PNPM_STORE_PATH}
222221 */
223222 public static get pnpmStorePathOverride ( ) : string | undefined {
224- EnvironmentConfiguration . _ensureInitialized ( ) ;
223+ EnvironmentConfiguration . _ensureValidated ( ) ;
225224 return EnvironmentConfiguration . _pnpmStorePathOverride ;
226225 }
227226
@@ -230,7 +229,7 @@ export class EnvironmentConfiguration {
230229 * See {@link EnvironmentVariableNames.RUSH_GLOBAL_FOLDER}
231230 */
232231 public static get rushGlobalFolderOverride ( ) : string | undefined {
233- EnvironmentConfiguration . _ensureInitialized ( ) ;
232+ EnvironmentConfiguration . _ensureValidated ( ) ;
234233 return EnvironmentConfiguration . _rushGlobalFolderOverride ;
235234 }
236235
@@ -239,7 +238,7 @@ export class EnvironmentConfiguration {
239238 * See {@link EnvironmentVariableNames.RUSH_BUILD_CACHE_CREDENTIAL}
240239 */
241240 public static get buildCacheCredential ( ) : string | undefined {
242- EnvironmentConfiguration . _ensureInitialized ( ) ;
241+ EnvironmentConfiguration . _ensureValidated ( ) ;
243242 return EnvironmentConfiguration . _buildCacheCredential ;
244243 }
245244
@@ -248,7 +247,7 @@ export class EnvironmentConfiguration {
248247 * See {@link EnvironmentVariableNames.RUSH_BUILD_CACHE_ENABLED}
249248 */
250249 public static get buildCacheEnabled ( ) : boolean | undefined {
251- EnvironmentConfiguration . _ensureInitialized ( ) ;
250+ EnvironmentConfiguration . _ensureValidated ( ) ;
252251 return EnvironmentConfiguration . _buildCacheEnabled ;
253252 }
254253
@@ -257,7 +256,7 @@ export class EnvironmentConfiguration {
257256 * See {@link EnvironmentVariableNames.RUSH_BUILD_CACHE_WRITE_ALLOWED}
258257 */
259258 public static get buildCacheWriteAllowed ( ) : boolean | undefined {
260- EnvironmentConfiguration . _ensureInitialized ( ) ;
259+ EnvironmentConfiguration . _ensureValidated ( ) ;
261260 return EnvironmentConfiguration . _buildCacheWriteAllowed ;
262261 }
263262
@@ -266,7 +265,7 @@ export class EnvironmentConfiguration {
266265 * See {@link EnvironmentVariableNames.RUSH_GIT_BINARY_PATH}
267266 */
268267 public static get gitBinaryPath ( ) : string | undefined {
269- EnvironmentConfiguration . _ensureInitialized ( ) ;
268+ EnvironmentConfiguration . _ensureValidated ( ) ;
270269 return EnvironmentConfiguration . _gitBinaryPath ;
271270 }
272271
@@ -288,7 +287,7 @@ export class EnvironmentConfiguration {
288287 /**
289288 * Reads and validates environment variables. If any are invalid, this function will throw.
290289 */
291- public static initialize ( options : IEnvironmentConfigurationInitializeOptions = { } ) : void {
290+ public static validate ( options : IEnvironmentConfigurationInitializeOptions = { } ) : void {
292291 EnvironmentConfiguration . reset ( ) ;
293292
294293 const unknownEnvVariables : string [ ] = [ ] ;
@@ -411,7 +410,7 @@ export class EnvironmentConfiguration {
411410 EnvironmentConfiguration . _rushGlobalFolderOverride =
412411 EnvironmentConfiguration . _getRushGlobalFolderOverride ( process . env ) ;
413412
414- EnvironmentConfiguration . _hasBeenInitialized = true ;
413+ EnvironmentConfiguration . _hasBeenValidated = true ;
415414 }
416415
417416 /**
@@ -420,14 +419,12 @@ export class EnvironmentConfiguration {
420419 public static reset ( ) : void {
421420 EnvironmentConfiguration . _rushTempFolderOverride = undefined ;
422421
423- EnvironmentConfiguration . _hasBeenInitialized = false ;
422+ EnvironmentConfiguration . _hasBeenValidated = false ;
424423 }
425424
426- private static _ensureInitialized ( ) : void {
427- if ( ! EnvironmentConfiguration . _hasBeenInitialized ) {
428- throw new InternalError (
429- 'The EnvironmentConfiguration must be initialized before values can be accessed.'
430- ) ;
425+ private static _ensureValidated ( ) : void {
426+ if ( ! EnvironmentConfiguration . _hasBeenValidated ) {
427+ EnvironmentConfiguration . validate ( ) ;
431428 }
432429 }
433430
0 commit comments