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
This commit is contained in:
Jimmy He 2024-01-01 14:14:37 -08:00 committed by GitHub
parent e603d7396b
commit 002bbc37b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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") { if (setupStrategy === "copy" || setupStrategy === "symlink") {
let originalFolder = sourceDirectory let originalFolder = sourceDirectory