Skip to content

Commit

Permalink
fix: fixed file/dir path for external reads
Browse files Browse the repository at this point in the history
  • Loading branch information
wernerglinka committed Feb 17, 2022
1 parent 760cdfd commit d3fc01e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,17 @@ function initMetadata(options) {
});

externalFiles.forEach(function(file) {
const extFilePromise = getFileObject(file.path, file.key, allMetadata);
const filePath = join(metalsmith.directory(), file.path);
const extFilePromise = getFileObject(filePath, file.key, allMetadata);

// add this promise to allPromises array. Will be later used with Promise.allSettled to invoke done()
allPromises.push(extFilePromise);
});

externalDirs.forEach(function(dir) {
// get content of all files in this directory, concatenated into one metadata object
const extDirectoryPromise = getDirectoryObject(dir.path, dir.key, allMetadata);
const directoryPath = join(metalsmith.directory(), dir.path);
const extDirectoryPromise = getDirectoryObject(directoryPath, dir.key, allMetadata);

// add this promise to allPromises array. Will be later used with Promise.allSettled to invoke done()
allPromises.push(extDirectoryPromise);
Expand Down
3 changes: 1 addition & 2 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe('metalsmith-metadata', () => {
done();
});
});
/*

it('should parse files in an external folder', (done) => {
metalsmith(fixture())
.use(
Expand Down Expand Up @@ -228,5 +228,4 @@ describe('metalsmith-metadata', () => {
done();
});
});
*/
});

0 comments on commit d3fc01e

Please sign in to comment.