Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return when done #173

Merged
merged 1 commit into from
Apr 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ module.exports = options => (files, metalsmith, done) => {

// Check whether the pattern option is valid
if (!(typeof settings.pattern === 'string' || Array.isArray(settings.pattern))) {
done(
return done(
new Error(
'invalid pattern, the pattern option should be a string or array of strings. See https://www.npmjs.com/package/metalsmith-layouts#pattern'
)
Expand All @@ -124,18 +124,19 @@ module.exports = options => (files, metalsmith, done) => {

// Let the user know when there are no files to process, unless the check is suppressed
if (validFiles.length === 0) {
const msg =
const message =
'no files to process. See https://www.npmjs.com/package/metalsmith-layouts#no-files-to-process';

if (settings.suppressNoFilesError) {
debug(msg);
done();
} else {
done(new Error(msg));
debug(message);
return done();
}

return done(new Error(message));
}

// Map all files that should be processed to an array of promises and call done when finished
Promise.all(
return Promise.all(
validFiles.map(filename => render({ filename, files, metadata, settings, metalsmith }))
)
.then(() => done())
Expand Down