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 }); + } +}