fix: remove environment specific .env reading

This commit is contained in:
Sérgio Salgado 2022-10-13 22:40:09 +01:00
parent df5bc81700
commit 8ad3b3eaad
3 changed files with 3 additions and 4 deletions

View file

@ -1,2 +1 @@
const path = require('path')
require('dotenv').config({ path: process.env.NODE_ENV === 'production' ? path.resolve('/etc', 'lamassu', '.env') : path.resolve(__dirname, '../.env') })
require('dotenv').config()

View file

@ -57,7 +57,7 @@ function updateOptionBasepath (result, optionName) {
async function run () {
// load current opts
const options = load().opts
const shouldMigrate = !fs.existsSync(process.env.NODE_ENV === 'production' ? path.resolve('/etc', 'lamassu', '.env') : path.resolve(__dirname, '../.env'))
const shouldMigrate = !fs.existsSync(path.resolve(__dirname, '../.env'))
// write the resulting .env
if (shouldMigrate) {

View file

@ -3,7 +3,7 @@ const os = require('os')
const path = require('path')
const setEnvVariable = (key, value) => {
const ENV_PATH = process.env.NODE_ENV === 'production' ? path.resolve('/etc', 'lamassu', '.env') : path.resolve(__dirname, '../.env')
const ENV_PATH = path.resolve(__dirname, '../.env')
const ENV_VARIABLES = fs.readFileSync(ENV_PATH, 'utf-8').split(os.EOL)
const target = ENV_VARIABLES.indexOf(ENV_VARIABLES.find(line => line.match(new RegExp(`^${key}=`))))