Skip to content

Commit

Permalink
fix: handle symlinked .git directories
Browse files Browse the repository at this point in the history
  • Loading branch information
liangzhicheng0423 committed Jan 26, 2022
1 parent 026aae0 commit 3a897ff
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/resolveGitRepo.js
Expand Up @@ -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
Expand Down

0 comments on commit 3a897ff

Please sign in to comment.