From 5edff7eb59d20ac70ba9206f63f2c60444c7003a Mon Sep 17 00:00:00 2001 From: Avris Date: Tue, 7 Sep 2021 19:11:15 +0200 Subject: [PATCH] #252 reorganise .env --- nuxt.config.js | 2 ++ server/calendar.js | 3 ++- server/cards.js | 3 ++- server/cleanupImages.js | 3 ++- server/notify.js | 3 ++- server/stats.js | 3 ++- src/dotenv.js | 8 ++++++++ 7 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 src/dotenv.js diff --git a/nuxt.config.js b/nuxt.config.js index 98463a11..58a4550f 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -1,3 +1,5 @@ +require('./src/dotenv')(); + import { loadSuml } from './server/loader'; import fs from 'fs'; import {buildDict, buildList, buildLocaleList} from "./src/helpers"; diff --git a/server/calendar.js b/server/calendar.js index a0c1b68a..5a76cefa 100644 --- a/server/calendar.js +++ b/server/calendar.js @@ -1,4 +1,5 @@ -require('dotenv').config({ path:__dirname + '/../.env' }); +require('../src/dotenv')(); + const Pageres = require('pageres'); const fs = require('fs'); const Suml = require('suml'); diff --git a/server/cards.js b/server/cards.js index 693da3d5..c9f8a41f 100644 --- a/server/cards.js +++ b/server/cards.js @@ -1,4 +1,5 @@ -require('dotenv').config({ path:__dirname + '/../.env' }); +require('../src/dotenv')(); + const Pageres = require('pageres'); const isHighLoadTime = require('./overload'); const dbConnection = require('./db'); diff --git a/server/cleanupImages.js b/server/cleanupImages.js index c35e04db..b14966c5 100644 --- a/server/cleanupImages.js +++ b/server/cleanupImages.js @@ -1,5 +1,6 @@ +require('../src/dotenv')(); + const dbConnection = require('./db'); -require('dotenv').config({ path:__dirname + '/../.env' }); const awsConfig = require('./aws'); const S3 = require('aws-sdk/clients/s3'); diff --git a/server/notify.js b/server/notify.js index c1265293..06accec4 100644 --- a/server/notify.js +++ b/server/notify.js @@ -1,5 +1,6 @@ +require('../src/dotenv')(); + const dbConnection = require('./db'); -require('dotenv').config({ path:__dirname + '/../.env' }); const mailer = require('../src/mailer'); // TODO duplication... diff --git a/server/stats.js b/server/stats.js index e92ea161..1e98fb6b 100644 --- a/server/stats.js +++ b/server/stats.js @@ -1,5 +1,6 @@ +require('../src/dotenv')(); + const dbConnection = require('./db'); -require('dotenv').config({ path:__dirname + '/../.env' }); const {calculateStats, statsFile} = require('../src/stats'); const locales = require('../src/locales'); const fs = require('fs'); diff --git a/src/dotenv.js b/src/dotenv.js new file mode 100644 index 00000000..58c5795f --- /dev/null +++ b/src/dotenv.js @@ -0,0 +1,8 @@ +const dotenv = require('dotenv'); + +module.exports = () => { + dotenv.config({ path:__dirname + '/../.env' }); + if (process.env.__INCLUDE) { + dotenv.config({ path:__dirname + '/../' + process.env.__INCLUDE }); + } +}