Refactor env parsing

This commit is contained in:
Rhys Arkins 2017-01-15 16:29:34 +01:00
parent 80487fbab9
commit ab585178bd

View file

@ -2,30 +2,11 @@ const logger = require('winston');
const config = {};
if (process.env.RENOVATE_REPOSITORIES) {
config.repositories = list(process.env.RENOVATE_REPOSITORIES);
if (process.env.RENOVATE_TOKEN) {
config.token = process.env.RENOVATE_TOKEN;
}
if (process.env.RENOVATE_DEP_TYPES) {
config.depTypes = list(process.env.RENOVATE_DEP_TYPES);
}
if (process.env.RENOVATE_RECREATE_PRS) {
if (process.env.RENOVATE_RECREATE_PRS === 'true') {
config.recreatePrs = true;
} else if (process.env.RENOVATE_RECREATE_PRS === 'false') {
config.recreatePrs = false;
} else {
logger.error('RENOVATE_RECREATE_PRS must be true or false');
process.exit(1);
}
}
if (process.env.RENOVATE_IGNORE_DEPS) {
config.ignoreDeps = list(process.env.RENOVATE_IGNORE_DEPS);
}
if (process.env.RENOVATE_LABELS) {
config.labels = list(process.env.RENOVATE_LABELS);
}
if (process.env.LOG_LEVEL) {
config.logLevel = process.env.LOG_LEVEL;
if (process.env.RENOVATE_REPOS) {
config.repositories = list(process.env.RENOVATE_REPOS);
}
if (process.env.RENOVATE_PACKAGE_FILES) {
if (config.repositories) {
@ -39,8 +20,27 @@ if (process.env.RENOVATE_PACKAGE_FILES) {
process.exit(1);
}
}
if (process.env.RENOVATE_TOKEN) {
config.token = process.env.RENOVATE_TOKEN;
if (process.env.RENOVATE_DEP_TYPES) {
config.depTypes = list(process.env.RENOVATE_DEP_TYPES);
}
if (process.env.RENOVATE_IGNORE_DEPS) {
config.ignoreDeps = list(process.env.RENOVATE_IGNORE_DEPS);
}
if (process.env.RENOVATE_LABELS) {
config.labels = list(process.env.RENOVATE_LABELS);
}
if (process.env.RENOVATE_RECREATE_PRS) {
if (process.env.RENOVATE_RECREATE_PRS === 'true') {
config.recreatePrs = true;
} else if (process.env.RENOVATE_RECREATE_PRS === 'false') {
config.recreatePrs = false;
} else {
logger.error('RENOVATE_RECREATE_PRS must be true or false');
process.exit(1);
}
}
if (process.env.LOG_LEVEL) {
config.logLevel = process.env.LOG_LEVEL;
}
logger.debug(`Env config: ${JSON.stringify(config)}`);