Skip to content

Commit

Permalink
feat(core): load root .env files on daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Apr 11, 2024
1 parent 2cb43ca commit 4e1c0a4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/nx/src/daemon/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { DaemonProjectGraphError } from '../daemon-project-graph-error';
import { ProjectGraphError } from '../../project-graph/project-graph';

const DAEMON_ENV_SETTINGS = {
...process.env,
NX_PROJECT_GLOB_CACHE: 'false',
NX_CACHE_PROJECTS_CONFIG: 'false',
};
Expand Down Expand Up @@ -402,7 +401,7 @@ export class DaemonClient {
detached: true,
windowsHide: true,
shell: false,
env: DAEMON_ENV_SETTINGS,
env: { ...process.env, ...DAEMON_ENV_SETTINGS },
}
);
backgroundProcess.unref();
Expand Down
17 changes: 17 additions & 0 deletions packages/nx/src/utils/dotenv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { config } from 'dotenv';
import { expand } from 'dotenv-expand';

/**
* This loads dotenv files from:
* - .env
* - .local.env
* - .env.local
*/
export function loadRootDotEnvFiles() {
for (const file of ['.local.env', '.env.local', '.env']) {
const myEnv = config({
path: file,
});
expand(myEnv);
}
}

0 comments on commit 4e1c0a4

Please sign in to comment.