File tree Expand file tree Collapse file tree 2 files changed +5
-11
lines changed Expand file tree Collapse file tree 2 files changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,6 @@ const fs = require('fs')
22const os = require ( "os" ) ;
33const path = require ( 'path' ) ;
44
5- const { packageVersion } = require ( './package.json' ) ;
6-
75const VALID_GIT_HOOKS = [
86 'applypatch-msg' ,
97 'pre-applypatch' ,
@@ -85,14 +83,9 @@ function getProjectRootDirectoryFromNodeModules(projectPath) {
8583
8684 const projDir = projectPath . split ( / [ \\ / ] / ) // <- would split both on '/' and '\'
8785
88- if ( projDir . includes ( '.pnpm' )
89- && projDir . length > 3
90- && _arraysAreEqual ( projDir . slice ( projDir . length - 3 ) , [
91- 'node_modules' ,
92- '.pnpm' ,
93- `simple-git-hooks@${ packageVersion } ` ,
94- ] ) ) {
95- return projDir . slice ( 0 , projDir . length - 3 ) . join ( '/' ) ;
86+ const indexOfPnpmDir = projDir . indexOf ( '.pnpm' )
87+ if ( indexOfPnpmDir > - 1 ) {
88+ return projDir . slice ( 0 , indexOfPnpmDir - 1 ) . join ( '/' ) ;
9689 }
9790
9891 // A yarn2 STAB
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ const os = require('os')
33const spc = require ( "./simple-git-hooks" ) ;
44const path = require ( "path" )
55
6- const { packageVersion } = require ( './package.json' ) ;
6+ const { version : packageVersion } = require ( './package.json' ) ;
77
88
99// Get project root directory
@@ -22,6 +22,7 @@ test('getProjectRootDirectory falls back to undefined when we are not in node_mo
2222
2323test ( 'getProjectRootDirectory return correct dir when installed using pnpm:' , ( ) => {
2424 expect ( spc . getProjectRootDirectoryFromNodeModules ( `var/my-project/node_modules/.pnpm/simple-git-hooks@${ packageVersion } ` ) ) . toBe ( 'var/my-project' )
25+ expect ( spc . getProjectRootDirectoryFromNodeModules ( `var/my-project/node_modules/.pnpm/simple-git-hooks@${ packageVersion } /node_modules/simple-git-hooks` ) ) . toBe ( 'var/my-project' )
2526} )
2627
2728
You can’t perform that action at this time.
0 commit comments