File tree 1 file changed +17
-3
lines changed
1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -35,15 +35,29 @@ export function loadEnv(
35
35
} ) ,
36
36
)
37
37
38
- // let environment variables use each other
39
- const expandParsed = expand ( {
38
+ const expandOptions = {
40
39
parsed : {
41
40
...( process . env as any ) ,
42
41
...parsed ,
43
42
} ,
44
43
// prevent process.env mutation
45
44
ignoreProcessEnv : true ,
46
- } ) . parsed !
45
+ }
46
+
47
+ let expandParsed : NonNullable < ReturnType < typeof expand > [ 'parsed' ] >
48
+ try {
49
+ // let environment variables use each other
50
+ expandParsed = expand ( expandOptions ) . parsed !
51
+ } catch ( e ) {
52
+ // custom error handling until https://github.com/motdotla/dotenv-expand/issues/65 is fixed upstream
53
+ // check for message "TypeError: Cannot read properties of undefined (reading 'split')"
54
+ if ( e . message . includes ( 'split' ) ) {
55
+ throw new Error (
56
+ 'dotenv-expand failed to expand env vars. Maybe you need to escape `$`?' ,
57
+ )
58
+ }
59
+ throw e
60
+ }
47
61
48
62
Object . keys ( parsed ) . forEach ( ( key ) => {
49
63
parsed [ key ] = expandParsed [ key ]
You can’t perform that action at this time.
0 commit comments