all repos — archive/homestead @ 75ef26ea24032c7e8a6a5d63e65c70d43c88a938

My future indieweb platform

fix(metadata): make return values consistent
Alan Pearce alan@alanpearce.eu
Sun, 18 Jun 2017 12:32:11 +0200
commit

75ef26ea24032c7e8a6a5d63e65c70d43c88a938

parent

db7c9f17bbfe026630448d5f24ed7d42e4d859ad

2 files changed, 5 insertions(+), 10 deletions(-)

jump to
M src/modules/metadata.jssrc/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.jstest/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 => {