fix: add environment file migration path null check

This commit is contained in:
Sérgio Salgado 2023-02-06 15:05:34 +00:00
parent 6624523134
commit 88826c430e

View file

@ -4,7 +4,7 @@ const path = require('path')
const _ = require('lodash/fp')
const setEnvVariable = (key, value, opts) => {
const ENV_PATH = !_.isNil(opts.ENV_PATH) ? opts.ENV_PATH : path.resolve(__dirname, '../.env')
const ENV_PATH = !_.isNil(opts?.ENV_PATH) ? opts.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}=`))))