From 8bf449bdc4c0cbc16627e92c55877ddef86bc68d Mon Sep 17 00:00:00 2001 From: Josh Harvey Date: Sat, 22 Sep 2018 18:51:00 +0100 Subject: [PATCH] add validate-config script --- bin/validate-config.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 bin/validate-config.js diff --git a/bin/validate-config.js b/bin/validate-config.js new file mode 100644 index 00000000..581f09d0 --- /dev/null +++ b/bin/validate-config.js @@ -0,0 +1,30 @@ +'use strict' + +const db = require('../lib/db') +const configValidate = require('../lib/config-validate') + +function pp (o) { + console.log(require('util').inspect(o, {depth: null, colors: true})) +} + +function dbFetchConfig () { + return db.oneOrNone( + 'select data from user_config where type=$1 order by created desc limit 1', + ['config'] + ) + .then(row => row && row.data) +} + +dbFetchConfig() + .then(config => { + pp(config) + return configValidate.validate(config.config) + }) + .then(() => { + console.log('success.') + process.exit(0) + }) + .catch(e => { + console.log(e) + process.exit(1) + })