feat: validate renovate config file (#3389)

Extend renovate-config-validator to validate `config.js` and `RENOVATE_CONFIG_FILE`. Also add the execute bit to `config-validator.js`

Fixed #3388
This commit is contained in:
Jamie Magee 2019-03-16 07:03:32 +01:00 committed by Rhys Arkins
parent 3e788c783a
commit 6aef5d2bc0

13
bin/config-validator.js Normal file → Executable file
View file

@ -3,6 +3,7 @@
const fs = require('fs-extra');
const { validateConfig } = require('../lib/config/validation');
const { massageConfig } = require('../lib/config/massage');
const { getConfig } = require('../lib/config/file');
const { initLogger } = require('../lib/logger');
const cache = require('../lib/workers/global/cache');
const { configFileNames } = require('../lib/config/app-strings');
@ -63,6 +64,18 @@ async function validate(desc, config, isPreset = false) {
} catch (err) {
// ignore
}
try {
const fileConfig = getConfig(process.env);
console.log(`Validating config.js`);
try {
await validate('config.js', fileConfig);
} catch (err) {
console.log(`config.js is not valid Renovate config`);
returnVal = 1;
}
} catch (err) {
// ignore
}
if (returnVal !== 0) {
process.exit(returnVal);
}