@@ -48,50 +48,21 @@ export function asEnvOptions(
48
48
}
49
49
50
50
/** Retrieve what app-config thinks the current deployment environment is (ie QA, dev, staging, production) */
51
- export function currentEnvironment ( options ?: EnvironmentOptions ) : string | undefined ;
52
-
53
- /** @deprecated use currentEnvironment(EnvironmentOptions) instead */
54
- export function currentEnvironment (
55
- environmentAliases ?: EnvironmentAliases ,
56
- environmentSourceNames ?: string [ ] | string ,
57
- ) : string | undefined ;
58
-
59
- export function currentEnvironment ( ...args : any [ ] ) : string | undefined {
51
+ export function currentEnvironment ( options ?: EnvironmentOptions ) : string | undefined {
60
52
let environmentSourceNames : string [ ] = defaultEnvVarNames ;
61
53
let environmentAliases : EnvironmentAliases = defaultAliases ;
62
54
let environmentOverride : string | undefined ;
63
55
64
- if (
65
- args [ 0 ] &&
66
- typeof args [ 0 ] === 'object' &&
67
- ( 'override' in args [ 0 ] || 'aliases' in args [ 0 ] || 'envVarNames' in args [ 0 ] )
68
- ) {
69
- const options = args [ 0 ] as EnvironmentOptions ;
70
-
71
- if ( options . override ) {
72
- environmentOverride = options . override ;
73
- }
74
-
75
- if ( options . aliases ) {
76
- environmentAliases = options . aliases ;
77
- }
56
+ if ( options ?. override ) {
57
+ environmentOverride = options . override ;
58
+ }
78
59
79
- if ( options . envVarNames ) {
80
- environmentSourceNames = options . envVarNames ;
81
- }
82
- } else {
83
- if ( args [ 0 ] ) {
84
- environmentAliases = args [ 0 ] as EnvironmentAliases ;
85
- logger . warn ( 'Detected deprecated usage of currentEnvironment' ) ;
86
- }
60
+ if ( options ?. aliases ) {
61
+ environmentAliases = options . aliases ;
62
+ }
87
63
88
- if ( Array . isArray ( args [ 1 ] ) ) {
89
- environmentSourceNames = args [ 1 ] as string [ ] ;
90
- logger . warn ( 'Detected deprecated usage of currentEnvironment' ) ;
91
- } else if ( typeof args [ 1 ] === 'string' ) {
92
- environmentSourceNames = [ args [ 1 ] ] ;
93
- logger . warn ( 'Detected deprecated usage of currentEnvironment' ) ;
94
- }
64
+ if ( options ?. envVarNames ) {
65
+ environmentSourceNames = options . envVarNames ;
95
66
}
96
67
97
68
if ( environmentOverride ) {
0 commit comments