18 lines
360 B
JavaScript
Executable File
18 lines
360 B
JavaScript
Executable File
const Ajv = require('ajv'),
|
|
constants = require('./util/constants')
|
|
|
|
const validate = new ajv().compile(constants.manifestSchema)
|
|
|
|
class ManifestParser {
|
|
constructor(manifestString) {
|
|
let data = JSON.parse(manifestString),
|
|
valid = validate(data)
|
|
|
|
if(!valid)
|
|
throw new Error('Uh oh, stinky!')
|
|
|
|
return data
|
|
}
|
|
}
|
|
|
|
module.exports = ManifestParser |