From 002bbc37b140d177276cd655049e7de2072fa537 Mon Sep 17 00:00:00 2001 From: Jimmy He <417267+hhe@users.noreply.github.com> Date: Mon, 1 Jan 2024 14:14:37 -0800 Subject: [PATCH] fix: Continue setup even if a file to delete is not found (#663) * Continue setup even if a file to delete is not found For various reasons, `.gitkeep` may be deleted already. (In my case, even though I followed the [Getting Started](https://quartz.jzhao.xyz) instructions exactly, my first run resulted in an `fatal: 'upstream' does not appear to be a git repository`) If we try to delete `.gitkeep` again and don't ignore `ENOENT`, then the whole setup fails. * Use fs.existsSync --- quartz/cli/handlers.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/quartz/cli/handlers.js b/quartz/cli/handlers.js index 586881a..37762a4 100644 --- a/quartz/cli/handlers.js +++ b/quartz/cli/handlers.js @@ -113,7 +113,10 @@ export async function handleCreate(argv) { } } - await fs.promises.unlink(path.join(contentFolder, ".gitkeep")) + const gitkeepPath = path.join(contentFolder, ".gitkeep") + if (fs.existsSync(gitkeepPath)) { + await fs.promises.unlink(gitkeepPath) + } if (setupStrategy === "copy" || setupStrategy === "symlink") { let originalFolder = sourceDirectory