Commit 56e01e35 authored by Dan Allen's avatar Dan Allen

use json5 to parse playbook spec file in JSON format

parent a926e98d
......@@ -5,6 +5,7 @@ const convict = require('./solitary-convict')
const cson = require('cson-parser')
const freezeDeep = require('deep-freeze')
const fs = require('fs')
const json = require('json5')
const path = require('path')
const yaml = require('js-yaml')
......@@ -18,7 +19,7 @@ const parseSpecFile = (specFilePath) => {
case '.yml':
return yaml.safeLoad(data)
case '.json':
return JSON.parse(data)
return json.parse(data)
case '.cson':
return cson.parse(data)
default:
......
// line comments are supported
{
"one": {
"one": "json-spec-value-one"
......@@ -6,12 +7,14 @@
"three": false,
"four": [
{
"name": "John",
"lastname": "Lennon"
// keys don't have to be quoted
// string values can be enclosed in single quotes
name: 'John',
lastname: 'Lennon'
},
{
"name": "Paul",
"lastname": "McCartney"
}
]
},
],
}
......@@ -87,7 +87,7 @@ describe('buildPlaybook()', () => {
expect(playbook).to.eql(expectedPlaybook)
})
it('should load JSON playbook spec file', () => {
it('should load JSON (JSON 5) playbook spec file', () => {
const playbook = buildPlaybook([], { PLAYBOOK: jsonSpec }, schema)
expectedPlaybook.one.one = 'json-spec-value-one'
expect(playbook).to.eql(expectedPlaybook)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment