File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
packages/cli-v3/src/utilities Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -11,14 +11,18 @@ export function resolveDotEnvVars(cwd?: string, envFile?: string) {
11
11
? resolve ( cwd ?? process . cwd ( ) , envFile )
12
12
: ENVVAR_FILES . map ( ( p ) => resolve ( cwd ?? process . cwd ( ) , p ) ) ;
13
13
14
- dotenv . config ( {
15
- processEnv : result ,
16
- path : envFilePath ,
14
+ // Load environment variables from the first found .env file
15
+ const { parsed } = dotenv . config ( {
16
+ path : Array . isArray ( envFilePath ) ? envFilePath . find ( path => fs . existsSync ( path ) ) : envFilePath ,
17
17
} ) ;
18
18
19
+ if ( parsed ) {
20
+ Object . assign ( result , parsed ) ;
21
+ }
22
+
19
23
env . TRIGGER_API_URL && ( result . TRIGGER_API_URL = env . TRIGGER_API_URL ) ;
20
24
21
- // remove TRIGGER_API_URL and TRIGGER_SECRET_KEY, since those should be coming from the worker
25
+ // Remove sensitive environment variables
22
26
delete result . TRIGGER_API_URL ;
23
27
delete result . TRIGGER_SECRET_KEY ;
24
28
delete result . OTEL_EXPORTER_OTLP_ENDPOINT ;
@@ -31,7 +35,8 @@ export function loadDotEnvVars(cwd?: string, envFile?: string) {
31
35
? resolve ( cwd ?? process . cwd ( ) , envFile )
32
36
: ENVVAR_FILES . map ( ( p ) => resolve ( cwd ?? process . cwd ( ) , p ) ) ;
33
37
38
+ // Load the first found .env file
34
39
dotenv . config ( {
35
- path : envFilePath ,
40
+ path : Array . isArray ( envFilePath ) ? envFilePath . find ( path => fs . existsSync ( path ) ) : envFilePath ,
36
41
} ) ;
37
42
}
You can’t perform that action at this time.
0 commit comments