From 0f86dbaf973b764d065b3c8c9f86afea533a3358 Mon Sep 17 00:00:00 2001 From: wearrrrr Date: Sat, 12 Oct 2024 03:13:45 -0500 Subject: [PATCH] do check for .git/hooks/pre-commit in a slightly more elegant way --- server.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/server.js b/server.js index d58a186..93b7f9b 100644 --- a/server.js +++ b/server.js @@ -86,12 +86,15 @@ fastify.listen({ }); console.log(`Listening on port ${PORT}`); -mkdirSync(".git/hooks", { recursive: true }); -writeFileSync( - ".git/hooks/pre-commit", - "pnpm prettier . -w\ngit update-index --again" -); -chmodSync(".git/hooks/pre-commit", 0o755); +try { + writeFileSync( + ".git/hooks/pre-commit", + "pnpm prettier . -w\ngit update-index --again" + ); + chmodSync(".git/hooks/pre-commit", 0o755); +} catch { + +} const watch = spawn("pnpm", ["rspack", "-w"], { detached: true,