Skip to content

Commit 002ae4b

Browse files
authored
Fix dotenv overrides for dev runs (#1388)
* override dashboard dev env vars with local .env * add changeset * add simple task for testing env vars
1 parent 047cb00 commit 002ae4b

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

.changeset/gentle-mails-smoke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
Local env files like `.env` will now correctly override dev env vars configured in the dashboard

packages/cli-v3/src/dev/backgroundWorker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,9 @@ export class BackgroundWorker {
319319
const processOptions: TaskRunProcessOptions = {
320320
payload,
321321
env: {
322-
...sanitizeEnvVars(this.params.env),
323322
// TODO: this needs the stripEmptyValues stuff too
324323
...sanitizeEnvVars(payload.environment ?? {}),
324+
...sanitizeEnvVars(this.params.env),
325325
TRIGGER_WORKER_MANIFEST_PATH: this.workerManifestPath,
326326
},
327327
serverWorker: this.serverWorker,

references/v3-catalog/src/trigger/other.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,11 @@ export const returnZeroCharacters = task({
156156
};
157157
},
158158
});
159+
160+
export const testEnvVars = task({
161+
id: "test-env-vars",
162+
run: async (payload: any) => {
163+
console.log(`env.FOO: ${process.env.FOO}`);
164+
console.log(`env.BAR: ${process.env.BAR}`);
165+
},
166+
});

0 commit comments

Comments
 (0)