diff --git a/docs-tools b/docs-tools index e52235b93..cf6daa12c 160000 --- a/docs-tools +++ b/docs-tools @@ -1 +1 @@ -Subproject commit e52235b937ceeb24e01534256d72cbb789c95b3d +Subproject commit cf6daa12c82c87b077617aa5e669ceb244d552e1 diff --git a/gatsby-node.js b/gatsby-node.js index 2265aeba6..3345a0b16 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -86,7 +86,7 @@ exports.createPages = async ({ actions }) => { // Save files in the static_files field of metadata document, including intersphinx inventories if (metadata.static_files) { - saveStaticFiles(metadata.static_files); + await saveStaticFiles(metadata.static_files); } return new Promise((resolve, reject) => { diff --git a/src/utils/setup/save-asset-files.js b/src/utils/setup/save-asset-files.js index 07f19e0a5..6a1389cae 100644 --- a/src/utils/setup/save-asset-files.js +++ b/src/utils/setup/save-asset-files.js @@ -15,22 +15,18 @@ const saveFile = async (file, data) => { // Write all assets to static directory const saveAssetFiles = async (assets, stitchClient) => { if (assets.length) { - const promises = []; const assetQuery = { _id: { $in: assets } }; const assetDataDocuments = await stitchClient.callFunction('fetchDocuments', [ database, ASSETS_COLLECTION, assetQuery, ]); - assetDataDocuments.forEach(({ filename, data: { buffer } }) => { - promises.push(saveFile(filename, buffer)); - }); - await Promise.all(promises); + await Promise.all(assetDataDocuments.map(({ filename, data: { buffer } }) => saveFile(filename, buffer))); } }; const saveStaticFiles = async staticFiles => { - Object.entries(staticFiles).forEach(([file, data]) => saveFile(file, data)); + await Promise.all(Object.entries(staticFiles).map(([file, data]) => saveFile(file, data.buffer))); }; module.exports = { saveAssetFiles, saveStaticFiles };