forked from lbl-srg/modelica-json
-
Notifications
You must be signed in to change notification settings - Fork 0
/
validation.js
51 lines (42 loc) · 1.06 KB
/
validation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const ut = require('./lib/util.js')
const logger = require('winston')
const fs = require('fs')
const ArgumentParser = require('argparse').ArgumentParser
/// ///////////////////////////////////////
var validation = new ArgumentParser({
version: '0.0.1',
addHelp: true,
description: 'Json file validation against schema'
})
validation.addArgument(
[ '-m', '--mode' ],
{
help: "Parsing mode, single CDL model or buildings modelica library package, 'cdl' is the default.",
choices: ['cdl', 'modelica'],
defaultValue: 'cdl'
}
)
validation.addArgument(
[ '-f', '--file' ],
{
help: 'JSON file to test against schema',
required: true
}
)
var args = validation.parseArgs()
const logFile = 'validation.log'
try {
fs.unlinkSync(logFile)
} catch (ex) {}
logger.configure({
transports: [
new logger.transports.Console(),
new logger.transports.File({ filename: logFile })
],
handleExceptions: true,
humanReadableUnhandledException: true
})
logger.cli()
logger.level = args.log
// Validation
ut.jsonSchemaValidate(args.mode, args.file)