Skip to content

Commit

Permalink
ensure yml files are {} if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkeller committed Oct 16, 2016
1 parent c98cb5d commit ff1269e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ var parsers = {
delete parserOptions.map
var loadMethod = parserOptions.loadMethod || 'safeLoad'
delete parserOptions.loadMethod
var data = yamlParser[loadMethod](str, parserOptions)
var data = yamlParser[loadMethod](str, parserOptions) || {}
return map(data, map)
},
aml: function (str, parserOptions) {
Expand Down
27 changes: 17 additions & 10 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1733,9 +1733,10 @@ describe('shorthandReaders', function () {

describe('readYamlSync()', function () {
describe('empty yaml', function () {
it('should be empty', function () {
it('should be empty object', function () {
var json = io.readYamlSync(testDataPath('yaml/empty.yaml'))
assert(_.isEmpty(json))
assert(_.isObject(json))
})
})

Expand Down Expand Up @@ -1769,9 +1770,10 @@ describe('shorthandReaders', function () {
})

describe('empty yml', function () {
it('should be empty', function () {
it('should be empty object', function () {
var json = io.readYamlSync(testDataPath('yml/empty.yml'))
assert(_.isEmpty(json))
assert(_.isObject(json))
})
})

Expand Down Expand Up @@ -1807,9 +1809,10 @@ describe('shorthandReaders', function () {

describe('readAmlSync()', function () {
describe('empty', function () {
it('should be empty', function () {
it('should be empty object', function () {
var json = io.readAmlSync(testDataPath('aml/empty.aml'))
assert(_.isEmpty(json))
assert(_.isObject(json))
})
})

Expand Down Expand Up @@ -2104,10 +2107,11 @@ describe('shorthandReaders', function () {

describe('readYaml()', function () {
describe('empty yaml', function () {
it('should be empty', function (done) {
it('should be empty object', function (done) {
io.readYaml(testDataPath('yaml/empty.yaml'), function (err, json) {
assert.equal(err, null)
assert(_.isEmpty(json))
assert(_.isObject(json))
done()
})
})
Expand All @@ -2124,10 +2128,11 @@ describe('shorthandReaders', function () {
})

describe('empty yml', function () {
it('should be empty', function (done) {
it('should be empty object', function (done) {
io.readYaml(testDataPath('yml/empty.yml'), function (err, json) {
assert.equal(err, null)
assert(_.isEmpty(json))
assert(_.isObject(json))
done()
})
})
Expand Down Expand Up @@ -2172,10 +2177,11 @@ describe('shorthandReaders', function () {
})

describe('empty yml', function () {
it('should be empty', function (done) {
it('should be empty object', function (done) {
io.readYaml(testDataPath('yml/empty.yml'), function (err, json) {
assert.equal(err, null)
assert(_.isEmpty(json))
assert(_.isObject(json))
done()
})
})
Expand Down Expand Up @@ -2237,10 +2243,11 @@ describe('shorthandReaders', function () {

describe('readAml()', function () {
describe('empty', function () {
it('should be empty', function (done) {
it('should be empty object', function (done) {
io.readAml(testDataPath('aml/empty.aml'), function (err, json) {
assert.equal(err, null)
assert(_.isEmpty(json))
assert(_.isObject(json))
done()
})
})
Expand Down Expand Up @@ -2286,9 +2293,9 @@ describe('shorthandReaders', function () {
})

// describe('readDbf()', function () {
// describe('basic', function () {
// it('should match expected json', function (done) {
// describe('empty', function () {
// it('should be empty array', function (done) {

// })
// })
// })
Expand Down

0 comments on commit ff1269e

Please sign in to comment.