Skip to content

Commit 33af460

Browse files
authored
Support node_modules created with bun install --linker=isolated (#136)
1 parent bcbc720 commit 33af460

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

simple-git-hooks.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ function getProjectRootDirectoryFromNodeModules(projectPath) {
114114
if (indexOfDenoDir > -1) {
115115
return projDir.slice(0, indexOfDenoDir - 1).join('/');
116116
}
117+
const indexOfBunDir = projDir.indexOf('.bun')
118+
if (indexOfBunDir > -1) {
119+
return projDir.slice(0, indexOfBunDir - 1).join('/');
120+
}
117121

118122
const indexOfStoreDir = projDir.indexOf('.store')
119123
if (indexOfStoreDir > -1) {

simple-git-hooks.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ describe("Simple Git Hooks tests", () => {
7272
)
7373
).toBe("var/my-project");
7474
});
75+
76+
it("return correct dir when installed using bun with --linker=isolated", () => {
77+
expect(
78+
simpleGitHooks.getProjectRootDirectoryFromNodeModules(
79+
`var/my-project/node_modules/.bun/simple-git-hooks@${packageVersion}/node_modules/simple-git-hooks`
80+
)
81+
).toBe('var/my-project');
82+
})
7583
});
7684

7785
describe("getGitProjectRoot", () => {

0 commit comments

Comments
 (0)