feat: flag option to toggle test db
This commit is contained in:
parent
c75319d166
commit
7794b91d20
1 changed files with 16 additions and 2 deletions
|
|
@ -3,6 +3,8 @@ const path = require('path')
|
||||||
const os = require('os')
|
const os = require('os')
|
||||||
const argv = require('minimist')(process.argv.slice(2))
|
const argv = require('minimist')(process.argv.slice(2))
|
||||||
|
|
||||||
|
const STRESS_TEST_DB = 'psql://postgres:postgres123@localhost/lamassu_stress'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {{path: string, opts: any}}
|
* @return {{path: string, opts: any}}
|
||||||
*/
|
*/
|
||||||
|
|
@ -25,17 +27,29 @@ function load () {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const globalConfigPath = path.resolve('/etc', 'lamassu', 'lamassu.json')
|
const globalConfigPath = path.resolve('/etc', 'lamassu', 'lamassu.json')
|
||||||
return {
|
const config = {
|
||||||
path: globalConfigPath,
|
path: globalConfigPath,
|
||||||
opts: JSON.parse(fs.readFileSync(globalConfigPath))
|
opts: JSON.parse(fs.readFileSync(globalConfigPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argv.testDB) {
|
||||||
|
config.opts.postgresql = STRESS_TEST_DB
|
||||||
|
}
|
||||||
|
|
||||||
|
return config
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
try {
|
try {
|
||||||
const homeConfigPath = path.resolve(os.homedir(), '.lamassu', 'lamassu.json')
|
const homeConfigPath = path.resolve(os.homedir(), '.lamassu', 'lamassu.json')
|
||||||
return {
|
const config = {
|
||||||
path: homeConfigPath,
|
path: homeConfigPath,
|
||||||
opts: JSON.parse(fs.readFileSync(homeConfigPath))
|
opts: JSON.parse(fs.readFileSync(homeConfigPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argv.testDB) {
|
||||||
|
config.opts.postgresql = STRESS_TEST_DB
|
||||||
|
}
|
||||||
|
|
||||||
|
return config
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
console.error("Couldn't open lamassu.json config file.")
|
console.error("Couldn't open lamassu.json config file.")
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue