File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed
Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -68,15 +68,16 @@ function envSchema (_opts) {
6868
6969 /* istanbul ignore else */
7070 if ( env ) {
71- if ( expandEnv ) {
72- require ( 'dotenv-expand' ) . expand ( { parsed : process . env } )
73- }
7471 data . unshift ( process . env )
7572 }
7673
7774 const merge = { }
7875 data . forEach ( d => Object . assign ( merge , d ) )
7976
77+ if ( expandEnv ) {
78+ require ( 'dotenv-expand' ) . expand ( { ignoreProcessEnv : true , parsed : merge } )
79+ }
80+
8081 const ajv = chooseAjvInstance ( sharedAjvInstance , opts . ajv )
8182
8283 const valid = ajv . validate ( schema , merge )
Original file line number Diff line number Diff line change @@ -46,6 +46,30 @@ const tests = [
4646 confExpected : {
4747 EXPANDED_VALUE_FROM_DOTENV : 'the password is password!'
4848 }
49+ } ,
50+ {
51+ name : 'simple object - ok - expandEnv works when passed an arbitrary new object based on process.env as data' ,
52+ schema : {
53+ type : 'object' ,
54+ properties : {
55+ URL : {
56+ type : 'string'
57+ } ,
58+ K8S_NAMESPACE : {
59+ type : 'string'
60+ }
61+ }
62+ } ,
63+ expandEnv : true ,
64+ isOk : true ,
65+ data : {
66+ ...process . env ,
67+ K8S_NAMESPACE : 'hello'
68+ } ,
69+ confExpected : {
70+ URL : 'https://prefix.hello.pluto.my.domain.com' ,
71+ K8S_NAMESPACE : 'hello'
72+ }
4973 }
5074]
5175
You can’t perform that action at this time.
0 commit comments