fix: clean up code
This commit is contained in:
parent
2c68323f66
commit
59de9e268e
2 changed files with 4 additions and 17 deletions
|
|
@ -4,8 +4,9 @@ const os = require('os')
|
||||||
const argv = require('minimist')(process.argv.slice(2))
|
const argv = require('minimist')(process.argv.slice(2))
|
||||||
const _ = require('lodash/fp')
|
const _ = require('lodash/fp')
|
||||||
|
|
||||||
require('dotenv').config({ path: `.env${process.env.NODE_ENV !== 'production' ? `.dev` : ``}` })
|
require('dotenv').config()
|
||||||
|
|
||||||
|
const dbPath = !process.env.LAMASSU_DB ? 'PROD' : process.env.LAMASSU_DB
|
||||||
const dbMapping = psqlConf => ({
|
const dbMapping = psqlConf => ({
|
||||||
STRESS_TEST: _.replace('lamassu', 'lamassu_stress', psqlConf),
|
STRESS_TEST: _.replace('lamassu', 'lamassu_stress', psqlConf),
|
||||||
RELEASE: _.replace('lamassu', 'lamassu_release', psqlConf),
|
RELEASE: _.replace('lamassu', 'lamassu_release', psqlConf),
|
||||||
|
|
@ -40,11 +41,7 @@ function load () {
|
||||||
opts: JSON.parse(fs.readFileSync(globalConfigPath))
|
opts: JSON.parse(fs.readFileSync(globalConfigPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
config.opts.postgresql = dbMapping(config.opts.postgresql)[
|
config.opts.postgresql = dbMapping(config.opts.postgresql)[dbPath]
|
||||||
process.env.LAMASSU_DB === '' || !process.env.LAMASSU_DB
|
|
||||||
? 'PROD'
|
|
||||||
: process.env.LAMASSU_DB
|
|
||||||
]
|
|
||||||
|
|
||||||
return config
|
return config
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
|
|
@ -55,17 +52,7 @@ function load () {
|
||||||
opts: JSON.parse(fs.readFileSync(homeConfigPath))
|
opts: JSON.parse(fs.readFileSync(homeConfigPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('flag', dbMapping(config.opts.postgresql)[
|
config.opts.postgresql = dbMapping(config.opts.postgresql)[dbPath]
|
||||||
process.env.LAMASSU_DB === '' || !process.env.LAMASSU_DB
|
|
||||||
? 'PROD'
|
|
||||||
: process.env.LAMASSU_DB
|
|
||||||
])
|
|
||||||
|
|
||||||
config.opts.postgresql = dbMapping(config.opts.postgresql)[
|
|
||||||
process.env.LAMASSU_DB === '' || !process.env.LAMASSU_DB
|
|
||||||
? 'PROD'
|
|
||||||
: process.env.LAMASSU_DB
|
|
||||||
]
|
|
||||||
|
|
||||||
return config
|
return config
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue