config-validator to consider default values from schema (#139)

* config-validator to consider default values from schema

* fix with relative json schema path

* remove lamassuServerPath config on lamassu-migrate-options
This commit is contained in:
Fabio Cigliano 2018-08-14 17:46:09 +02:00 committed by Josh Harvey
parent d28c6ae691
commit 6fdb3e8834
7 changed files with 13 additions and 16 deletions

View file

@ -25,11 +25,14 @@ async function run () {
const currentOpts = options.opts
// check if there are new options to add
const result = _.mergeAll([defaultOpts, currentOpts])
const shouldMigrate = !_.isEqual(result, currentOpts)
let result = _.mergeAll([defaultOpts, currentOpts])
const shouldMigrate = !_.isEqual(result, currentOpts) || _.has('lamassuServerPath', result)
// write the resulting lamassu.json
if (shouldMigrate) {
// remove old lamassuServerPath config
result = _.omit('lamassuServerPath', result)
const newOpts = _.pick(_.difference(_.keys(result), _.keys(currentOpts)), result)
console.log('Adding options', newOpts)