From b7df851460b2f85ab8ede7951a1cf66c3621cdaf Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Mon, 15 Jun 2020 21:20:09 +0800 Subject: [PATCH] perf(v2): convert Promise style to async/await style for consistency --- packages/docusaurus-plugin-content-blog/src/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/docusaurus-plugin-content-blog/src/index.ts b/packages/docusaurus-plugin-content-blog/src/index.ts index aa4d3a32ca82..6dd807a524d0 100644 --- a/packages/docusaurus-plugin-content-blog/src/index.ts +++ b/packages/docusaurus-plugin-content-blog/src/index.ts @@ -441,16 +441,18 @@ export default function pluginContentBlog( const feedTypes = getFeedTypes(options.feedOptions?.type); await Promise.all( - feedTypes.map((feedType) => { + feedTypes.map(async (feedType) => { const feedPath = path.join( outDir, options.routeBasePath, `${feedType}.xml`, ); const feedContent = feedType === 'rss' ? feed.rss2() : feed.atom1(); - return fs.outputFile(feedPath, feedContent).catch((err) => { + try { + await fs.outputFile(feedPath, feedContent); + } catch (err) { throw new Error(`Generating ${feedType} feed failed: ${err}`); - }); + } }), ); },