Skip to content

Commit

Permalink
tweak(environment): RN-1225: Override with local env if exists (#5564)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexd-bes authored Apr 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 1287db2 commit 56032fe
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 0 additions & 1 deletion packages/database/src/configureEnv.js
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@ export const configureEnv = () => {
path: [
path.resolve(__dirname, '../../../env/db.env'),
path.resolve(__dirname, '../../../env/pg.env'),
path.resolve(__dirname, '../.env'),
],
});
};
10 changes: 9 additions & 1 deletion packages/server-utils/src/configureDotEnv.ts
Original file line number Diff line number Diff line change
@@ -6,5 +6,13 @@
import dotenv from 'dotenv';

export const configureDotEnv = (envFiles: string[]) => {
dotenv.config({ path: envFiles });
const filesThatExistInSystem = envFiles.filter(file => {
try {
require.resolve(file);
return true;
} catch (error) {
return false;
}
});
dotenv.config({ path: filesThatExistInSystem, override: true });
};
3 changes: 2 additions & 1 deletion packages/types/generate-models.ts
Original file line number Diff line number Diff line change
@@ -15,7 +15,8 @@ import config from './config/models/config.json';
import * as dotenv from 'dotenv';
import * as fs from 'fs';
dotenv.config({
path: [path.resolve(__dirname, '../../../env/db.env'), path.resolve(__dirname, '.env')],
path: [path.resolve(__dirname, '../../env/db.env'), path.resolve(__dirname, '.env')],
override: true,
});

const db = Knex({

0 comments on commit 56032fe

Please sign in to comment.