File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -469,13 +469,18 @@ export const cli = yargs
469
469
description : 'Validates only using one environment' ,
470
470
group : OptionGroups . Options ,
471
471
} ,
472
+ includeNoEnvironment : {
473
+ type : 'boolean' ,
474
+ description : 'Validates config with no environment selected' ,
475
+ group : OptionGroups . Options ,
476
+ } ,
472
477
} ,
473
478
} ,
474
- async ( { environment } ) => {
479
+ async ( { environment, includeNoEnvironment } ) => {
475
480
if ( environment ) {
476
481
await loadValidatedConfig ( { environmentOverride : environment } ) ;
477
482
} else {
478
- await validateAllConfigVariants ( ) ;
483
+ await validateAllConfigVariants ( { includeNoEnvironment } ) ;
479
484
}
480
485
} ,
481
486
) ,
Original file line number Diff line number Diff line change @@ -6,11 +6,13 @@ import { loadValidatedConfig } from '@app-config/config';
6
6
export interface Options {
7
7
directory ?: string ;
8
8
environmentAliases ?: EnvironmentAliases ;
9
+ includeNoEnvironment ?: boolean ;
9
10
}
10
11
11
12
export async function validateAllConfigVariants ( {
12
13
directory = '.' ,
13
14
environmentAliases = defaultAliases ,
15
+ includeNoEnvironment = false ,
14
16
} : Options = { } ) {
15
17
// first, we have to find any applicable app-config files
16
18
// this is less trivial than config loading, because we can't "assume" the current environment (it could be anything)
@@ -68,4 +70,13 @@ export async function validateAllConfigVariants({
68
70
environmentVariableName : '' , // do not load APP_CONFIG
69
71
} ) ;
70
72
}
73
+
74
+ if ( includeNoEnvironment || appConfigEnvironments . size === 0 ) {
75
+ logger . info ( `Validating configuration for no environment` ) ;
76
+
77
+ await loadValidatedConfig ( {
78
+ directory,
79
+ environmentVariableName : '' , // do not load APP_CONFIG
80
+ } ) ;
81
+ }
71
82
}
You can’t perform that action at this time.
0 commit comments