diff options
-rw-r--r-- | src/modules/metadata.js | 9 | ||||
-rw-r--r-- | test/modules/metadata.test.js | 6 |
2 files changed, 5 insertions, 10 deletions
diff --git a/src/modules/metadata.js b/src/modules/metadata.js index 9f24d8e..f35031d 100644 --- a/src/modules/metadata.js +++ b/src/modules/metadata.js @@ -24,20 +24,15 @@ function canonicaliseMetadata (meta) { return meta } -function readFileMetadata (filename) { - return canonicaliseMetadata(matter.read(filename, options)) -} - function getFileMetadata (filename) { - const result = readFileMetadata(filename) - return result && result.data + return canonicaliseMetadata(matter.read(filename, options)) } function getFolderMetadata (folder) { return fs .readdirSync(folder) .map(f => path.resolve(folder, f)) - .map(readFileMetadata) + .map(getFileMetadata) } module.exports = { diff --git a/test/modules/metadata.test.js b/test/modules/metadata.test.js index 139de60..f154eac 100644 --- a/test/modules/metadata.test.js +++ b/test/modules/metadata.test.js @@ -11,10 +11,10 @@ test('getFileMetadata', t => { 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 => { |