From 5d064ac8731fc9fe780dffbf2539c305d63472fa Mon Sep 17 00:00:00 2001 From: Maik Stegemann <55740298+SecTex@users.noreply.github.com> Date: Thu, 30 Mar 2023 08:42:02 +0200 Subject: [PATCH] fix(githook.ts): fix SYMLINK_URL for Windows (#88) * fix(githook.ts): fix SYMLINK_URL for Windows * refactor(githook.ts): use path.join to create SYMLINK_URL The SYMLINK_URL variable is now created using the path.join method, which is more platform-independent and ensures that the correct path separator is used. This improves the reliability of the code and makes it easier to maintain. --------- Co-authored-by: Maik Stegemann --- package-lock.json | 6 ------ src/commands/githook.ts | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index c4a81a7..e5efccd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "license": "MIT", "dependencies": { "@clack/prompts": "^0.6.1", - "@dqbd/tiktoken": "^1.0.2", "axios": "^1.3.4", "chalk": "^5.2.0", "cleye": "^1.3.2", @@ -84,11 +83,6 @@ "node": ">=12" } }, - "node_modules/@dqbd/tiktoken": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@dqbd/tiktoken/-/tiktoken-1.0.2.tgz", - "integrity": "sha512-AjGTBRWsMoVmVeN55NLyupyM8TNamOUBl6tj5t/leLDVup3CFGO9tVagNL1jf3GyZLkWZSTmYVbPQ/M2LEcNzw==" - }, "node_modules/@esbuild/android-arm": { "version": "0.15.18", "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.15.18.tgz", diff --git a/src/commands/githook.ts b/src/commands/githook.ts index 12a817c..505c1c9 100755 --- a/src/commands/githook.ts +++ b/src/commands/githook.ts @@ -8,9 +8,9 @@ import { intro, outro } from '@clack/prompts'; import { COMMANDS } from '../CommandsEnum.js'; const HOOK_NAME = 'prepare-commit-msg'; -const SYMLINK_URL = `.git/hooks/${HOOK_NAME}`; +const SYMLINK_URL = path.join(path.sep, '.git', 'hooks', HOOK_NAME); -export const isHookCalled = process.argv[1].endsWith(`/${SYMLINK_URL}`); +export const isHookCalled = process.argv[1].endsWith(`${SYMLINK_URL}`); const isHookExists = existsSync(SYMLINK_URL);