lib/config: add environment variable to set config file

Previously it was assumed that `config.json` would be placed in
the same directory as the rest of CodiMD without any optional override.

This allows to override the path to the `config.json` by setting
`CMD_CONFIG_FILE` to the canonical path of the desired config file.

Signed-off-by: WilliButz <wbutz@cyberfnord.de>
This commit is contained in:
WilliButz 2018-09-05 19:50:46 +02:00
parent bd2f7cef49
commit e48852e0e2
No known key found for this signature in database
GPG key ID: 92582A10F1179CB2

View file

@ -23,7 +23,8 @@ const packageConfig = {
minimumCompatibleVersion: '0.5.0'
}
const configFilePath = path.join(appRootPath, 'config.json')
const configFilePath = path.resolve(appRootPath, process.env.CMD_CONFIG_FILE ||
'config.json')
const fileConfig = fs.existsSync(configFilePath) ? require(configFilePath)[env] : undefined
let config = require('./default')