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
1 changed files with 2 additions and 1 deletions

View File

@ -23,7 +23,8 @@ const packageConfig = {
minimumCompatibleVersion: '0.5.0' 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 const fileConfig = fs.existsSync(configFilePath) ? require(configFilePath)[env] : undefined
let config = require('./default') let config = require('./default')