File tree Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Original file line number Diff line number Diff line change 1
1
const Ajv = require ( 'ajv' ) ;
2
2
const metaSchema = require ( 'ajv/lib/refs/json-schema-draft-06.json' ) ;
3
+ const logger = require ( './logger' ) ;
3
4
const configSchema = require ( './schemas/config.schema.json' ) ;
4
5
5
6
const ajv = new Ajv ( { logger : false , allErrors : true } ) ;
6
7
ajv . addMetaSchema ( metaSchema ) ;
7
8
const validator = ajv . addSchema ( configSchema , 'config' ) ;
8
9
9
10
function validateConfig ( config ) {
11
+ logger . debug ( 'Validating config file' ) ;
10
12
const valid = validator . validate ( 'config' , config ) ;
11
13
const errors = ajv . errorsText ( validator . errors , { dataVar : 'config' } ) ;
12
14
if ( ! valid ) throw new Error ( `Error(s) found in config file: ${ errors } ` ) ;
15
+ logger . debug ( 'Config file validated successfully' ) ;
13
16
}
14
17
15
18
module . exports = {
You can’t perform that action at this time.
0 commit comments