refactor(v2): convert synchronous file write to asynchronous (#2936)

* perf(v2): convert synchronous filewrite to asynchronous in feed file generate

This looks like should return a Promise list , other than a sync io operation

* perf(v2): convert synchronous filewrite to asynchronous in sitemap generate

* perf(v2): convert  Promise style to async/await style

for consistency
This commit is contained in:
moonrailgun 2020-06-15 22:04:15 +08:00 committed by GitHub
parent 0c92f5aacd
commit 930222ea87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import fs from 'fs';
import fs from 'fs-extra';
import path from 'path';
import {PluginOptions} from './types';
import createSitemap from './createSitemap';
@ -37,7 +37,7 @@ export default function pluginSitemap(
// Write sitemap file.
const sitemapPath = path.join(outDir, 'sitemap.xml');
try {
fs.writeFileSync(sitemapPath, generatedSitemap);
await fs.outputFile(sitemapPath, generatedSitemap);
} catch (err) {
throw new Error(`Sitemap error: ${err}`);
}