renovate/lib/config/file.js
Rhys Arkins 00d6249711 Refactor config
Now generates CLI, env and docs
Makes config more testable
2017-01-20 14:03:18 +01:00

26 lines
577 B
JavaScript

const logger = require('winston');
module.exports = {
getConfig,
isPathAbsolute,
};
function getConfig(env) {
let configFile = env.RENOVATE_CONFIG_FILE || 'config';
if (!isPathAbsolute(configFile)) {
configFile = `../../${configFile}`;
}
let config = {};
try {
// eslint-disable-next-line global-require,import/no-dynamic-require
config = require(configFile);
} catch (err) {
// Do nothing
logger.verbose('Could not locate config file');
}
return config;
}
function isPathAbsolute(path) {
return /^(?:\/|[a-z]+:\/\/)/.test(path);
}