feat: backport database selector flag
This commit is contained in:
parent
c819a354bc
commit
81fa63f630
3 changed files with 12 additions and 8 deletions
|
|
@ -2,8 +2,15 @@ const fs = require('fs')
|
|||
const path = require('path')
|
||||
const os = require('os')
|
||||
const argv = require('minimist')(process.argv.slice(2))
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const STRESS_TEST_DB = 'psql://postgres:postgres123@localhost/lamassu_stress'
|
||||
require('dotenv').config()
|
||||
|
||||
const dbMapping = psqlConf => ({
|
||||
STRESS_TEST: _.replace('lamassu', 'lamassu_stress', psqlConf),
|
||||
RELEASE: _.replace('lamassu', 'lamassu_release', psqlConf),
|
||||
DEV: _.replace('lamassu', 'lamassu', psqlConf)
|
||||
})
|
||||
|
||||
/**
|
||||
* @return {{path: string, opts: any}}
|
||||
|
|
@ -32,9 +39,7 @@ function load () {
|
|||
opts: JSON.parse(fs.readFileSync(globalConfigPath))
|
||||
}
|
||||
|
||||
if (argv.testDB) {
|
||||
config.opts.postgresql = STRESS_TEST_DB
|
||||
}
|
||||
config.opts.postgresql = dbMapping(config.opts.postgresql)[process.env.LAMASSU_DB]
|
||||
|
||||
return config
|
||||
} catch (_) {
|
||||
|
|
@ -45,9 +50,7 @@ function load () {
|
|||
opts: JSON.parse(fs.readFileSync(homeConfigPath))
|
||||
}
|
||||
|
||||
if (argv.testDB) {
|
||||
config.opts.postgresql = STRESS_TEST_DB
|
||||
}
|
||||
config.opts.postgresql = dbMapping(config.opts.postgresql)[process.env.LAMASSU_DB]
|
||||
|
||||
return config
|
||||
} catch (_) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue