diff --git a/simple-git-hooks.js b/simple-git-hooks.js index f909846..aa6e773 100644 --- a/simple-git-hooks.js +++ b/simple-git-hooks.js @@ -87,6 +87,11 @@ function getProjectRootDirectoryFromNodeModules(projectPath) { return projDir.slice(0, indexOfPnpmDir - 1).join('/'); } + const indexOfStoreDir = projDir.indexOf('.store') + if (indexOfStoreDir > -1) { + return projDir.slice(0, indexOfStoreDir - 1).join('/'); + } + // A yarn2 STAB if (projDir.includes('.yarn') && projDir.includes('unplugged')) { return undefined diff --git a/simple-git-hooks.test.js b/simple-git-hooks.test.js index 137891b..d4338e7 100644 --- a/simple-git-hooks.test.js +++ b/simple-git-hooks.test.js @@ -24,6 +24,10 @@ test('getProjectRootDirectory return correct dir when installed using pnpm:', () expect(spc.getProjectRootDirectoryFromNodeModules(`var/my-project/node_modules/.pnpm/simple-git-hooks@${packageVersion}/node_modules/simple-git-hooks`)).toBe('var/my-project') }) +test('getProjectRootDirectory return correct dir when installed using yarn3 nodeLinker pnpm:', () => { + expect(spc.getProjectRootDirectoryFromNodeModules(`var/my-project/node_modules/.store/simple-git-hooks@${packageVersion}/node_modules/simple-git-hooks`)).toBe('var/my-project') +}) + // Get git root