From 3a897ff1515bde9fc88769257f38cb2646d624fc Mon Sep 17 00:00:00 2001 From: lzc <92916529+liangzhicheng0423@users.noreply.github.com> Date: Thu, 27 Jan 2022 02:02:53 +0800 Subject: [PATCH] fix: handle symlinked .git directories --- lib/resolveGitRepo.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/resolveGitRepo.js b/lib/resolveGitRepo.js index 23b03832c..3e7460369 100644 --- a/lib/resolveGitRepo.js +++ b/lib/resolveGitRepo.js @@ -14,7 +14,8 @@ const debugLog = debug('lint-staged:resolveGitRepo') * submodules and worktrees */ const resolveGitConfigDir = async (gitDir) => { - const defaultDir = normalize(path.join(gitDir, '.git')) + // Get the real path in case it's a symlink + const defaultDir = normalize(await fs.realpath(path.join(gitDir, '.git'))) const stats = await fs.lstat(defaultDir) // If .git is a directory, use it if (stats.isDirectory()) return defaultDir