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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#! /bin/env node
var validate = require('jsonschema').validate;
var fs = require('fs');
var readline = require('readline');
var schema = '';
var testCode = '';
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
rl.on('line', function(line){
fs.readFile('simple-schema.json', function(err, data) {
if (err) {
throw err;
}
schema = JSON.parse(data);
fs.readFile(line, function(err, data) {
if (err) {
throw err;
}
try {
testCode = JSON.parse(data);
} catch(e) {
debugger;
}
try {
var x = validate(testCode, schema);
} catch(e) {
console.log(line);
}
});
});
});
/*
fs.readFile('simple-schema.json', function(err, data) {
if (err) {
throw err;
}
schema = JSON.parse(data);
fs.readFile('example.json', function(err, data) {
if (err) {
throw err;
}
testCode = JSON.parse(data);
var x = validate(testCode, schema);
console.log(x);
debugger;
});
});
*/
|