-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathverify.js
42 lines (34 loc) · 1.01 KB
/
verify.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
const _ = require('lodash')
const chalk = require('chalk')
const books = require('./js/books.json')
const osis = require('./js/osis.json')
let exitCode = 0
let totalVerseCount = 0
osis.forEach(osis => {
const id = osis.id
const book = _.find(books, {id})
totalVerseCount += book.verseCount
const chapterCount = book.chapters.length
const verseCount = _.sum(book.chapters)
if (chapterCount === 0) {
exitCode = 1
console.warn(chalk.yellow(id + '\t SKIPPING'))
} else {
let failures = ''
if (chapterCount !== osis.chapters) failures += ' - chapter count'
if (verseCount !== book.verseCount) failures += ' - verse count'
if (failures.length === 0) {
console.log(chalk.green(id + '\t PASSED'))
} else {
exitCode = 1
console.error(chalk.red(id + '\t FAILED FOR' + failures))
}
}
})
if (totalVerseCount === 31103) {
console.log(chalk.green('CHECKSUM IS CORRECT'))
} else {
exitCode = 1
console.error(chalk.red('CHECKSUM IS WRONG'))
}
process.exit(exitCode)