From 3ebee74efca7664438afc1635880d0c87530434b Mon Sep 17 00:00:00 2001 From: weishu Date: Sat, 21 Oct 2023 10:28:23 +0800 Subject: [PATCH] website: Fix template index.json generate error --- website/docs/.vitepress/config.ts | 13 +++++++++---- website/docs/public/templates/.gitignore | 2 -- 2 files changed, 9 insertions(+), 6 deletions(-) delete mode 100644 website/docs/public/templates/.gitignore diff --git a/website/docs/.vitepress/config.ts b/website/docs/.vitepress/config.ts index 0df204369d7a..057125edbd46 100644 --- a/website/docs/.vitepress/config.ts +++ b/website/docs/.vitepress/config.ts @@ -7,9 +7,14 @@ export default defineConfig( { title: 'KernelSU', locales: locales.locales, buildEnd: async (config: SiteConfig) => { - const templateDir = resolve(config.outDir, 'templates') - const files = await readdir(templateDir); - const templateList = resolve(templateDir, "index.json") - await writeFile(templateList, JSON.stringify(files)) + const templateDir = resolve(config.outDir, 'templates'); + const templateList = resolve(templateDir, "index.json"); + let files = []; + try { + files = await readdir(templateDir); + } catch(e) { + // ignore + } + await writeFile(templateList, JSON.stringify(files)); } }) \ No newline at end of file diff --git a/website/docs/public/templates/.gitignore b/website/docs/public/templates/.gitignore deleted file mode 100644 index 5fa0ad4dafd8..000000000000 --- a/website/docs/public/templates/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# we generate index.json at build time -index.json