fix: failed to create dir when ./dist not exist

This commit is contained in:
leafee98 2023-07-14 20:58:02 +08:00
parent ba2e6f6376
commit 056ba6d410

View file

@ -80,7 +80,7 @@ function serve(config, nunjucks_env) {
function generate(config, nunjucks_env) { function generate(config, nunjucks_env) {
const rendered = nunjucks_env.render(template_path, config); const rendered = nunjucks_env.render(template_path, config);
if (! fs.existsSync(path.dirname(output_path))) { if (! fs.existsSync(path.dirname(output_path))) {
fs.mkdirSync(fs.dirname(output_path), { recursive: true }); fs.mkdirSync(path.dirname(output_path), { recursive: true });
} }
fs.writeFileSync(output_path, rendered); fs.writeFileSync(output_path, rendered);
} }