Skip to content

Update dotEnv.ts #1339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions packages/cli-v3/src/utilities/dotEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ export function resolveDotEnvVars(cwd?: string, envFile?: string) {
? resolve(cwd ?? process.cwd(), envFile)
: ENVVAR_FILES.map((p) => resolve(cwd ?? process.cwd(), p));

dotenv.config({
processEnv: result,
path: envFilePath,
// Load environment variables from the first found .env file
const { parsed } = dotenv.config({
path: Array.isArray(envFilePath) ? envFilePath.find(path => fs.existsSync(path)) : envFilePath,
});

if (parsed) {
Object.assign(result, parsed);
}

env.TRIGGER_API_URL && (result.TRIGGER_API_URL = env.TRIGGER_API_URL);

// remove TRIGGER_API_URL and TRIGGER_SECRET_KEY, since those should be coming from the worker
// Remove sensitive environment variables
delete result.TRIGGER_API_URL;
delete result.TRIGGER_SECRET_KEY;
delete result.OTEL_EXPORTER_OTLP_ENDPOINT;
Expand All @@ -31,7 +35,8 @@ export function loadDotEnvVars(cwd?: string, envFile?: string) {
? resolve(cwd ?? process.cwd(), envFile)
: ENVVAR_FILES.map((p) => resolve(cwd ?? process.cwd(), p));

// Load the first found .env file
dotenv.config({
path: envFilePath,
path: Array.isArray(envFilePath) ? envFilePath.find(path => fs.existsSync(path)) : envFilePath,
});
}