fix(metadata): make return values consistent
Alan Pearce alan@alanpearce.eu
Sun, 18 Jun 2017 12:32:11 +0200
2 files changed, 5 insertions(+), 10 deletions(-)
M src/modules/metadata.js → src/modules/metadata.js
@@ -24,20 +24,15 @@ } return meta } -function readFileMetadata (filename) { +function getFileMetadata (filename) { return canonicaliseMetadata(matter.read(filename, options)) } -function getFileMetadata (filename) { - const result = readFileMetadata(filename) - return result && result.data -} - function getFolderMetadata (folder) { return fs .readdirSync(folder) .map(f => path.resolve(folder, f)) - .map(readFileMetadata) + .map(getFileMetadata) } module.exports = {
M test/modules/metadata.test.js → test/modules/metadata.test.js
@@ -11,10 +11,10 @@ description: 'Test file', tags: ['a', 'b'] }) ) - t.deepEqual( - metadata.getFileMetadata(path.resolve(__dirname, '../data/testfile.md')), - expected + const meta = metadata.getFileMetadata( + path.resolve(__dirname, '../data/testfile.md') ) + t.deepEqual(meta.data, expected) }) test('getFolderMetadata', t => {