fix(v2): Use writeFileSync to write generated sitemap.xml to avoid early termination (#2530)

This commit is contained in:
Sam Zhou 2020-04-05 00:18:49 -04:00 committed by GitHub
parent 84baab33b4
commit 46452350df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,11 +36,11 @@ export default function pluginSitemap(
// Write sitemap file.
const sitemapPath = path.join(outDir, 'sitemap.xml');
fs.writeFile(sitemapPath, generatedSitemap, err => {
if (err) {
throw new Error(`Sitemap error: ${err}`);
}
});
try {
fs.writeFileSync(sitemapPath, generatedSitemap);
} catch (err) {
throw new Error(`Sitemap error: ${err}`);
}
},
};
}