@@ -7,7 +7,10 @@ module.exports = {
7
7
var p = findGitDir ( ) ;
8
8
9
9
return p . then ( function ( gitDir ) {
10
- return path . resolve ( gitDir , './.git/hooks/pre-commit' ) ;
10
+ return {
11
+ hookFile : path . resolve ( gitDir , './.git/hooks/pre-commit' ) ,
12
+ gitDir : gitDir
13
+ } ;
11
14
} ) ;
12
15
} ,
13
16
install : function ( cfg ) {
@@ -27,17 +30,22 @@ module.exports = {
27
30
28
31
prepushSource = prepushSource . replace ( / r e q u i r e \( \s * ' p r o c e s s ' \s * \) ; / g, 'process;' )
29
32
. replace ( / r e q u i r e \( \s * ' c o n s o l e ' \s * \) ; / g, 'console;' )
30
- . replace ( / r e q u i r e \( \s * ' \. \/ P r o m i s e ' \s * \) ; / g, 'global.Promise;' )
31
- . replace ( / r e q u i r e \( \s * ' p r e c o m m i t - c o n f i g ' \s * \) ; / g, JSON . stringify ( cfg , null , 2 ) + ';' ) ;
33
+ . replace ( / r e q u i r e \( \s * ' \. \/ P r o m i s e ' \s * \) ; / g, 'global.Promise;' ) ;
34
+
35
+
36
+ return this . _pathToFile ( ) . then ( function ( args ) {
37
+ var pathToFile = args . hookFile ;
38
+ cfg . gitDirectory = args . gitDir ;
39
+ prepushSource = prepushSource . replace ( / r e q u i r e \( \s * ' p r e c o m m i t - c o n f i g ' \s * \) ; / g, JSON . stringify ( cfg , null , 2 ) + ';' ) ;
32
40
33
- return this . _pathToFile ( ) . then ( function ( pathToFile ) {
34
41
write ( pathToFile , prepushSource ) ;
35
42
fs . chmodSync ( pathToFile , '755' ) ;
36
43
return pathToFile ;
37
44
} ) ;
38
45
} ,
39
46
remove : function ( ) {
40
- return this . _pathToFile ( ) . then ( function ( pathToFile ) {
47
+ return this . _pathToFile ( ) . then ( function ( args ) {
48
+ var pathToFile = args . hookFile ;
41
49
var del = require ( 'del' ) ;
42
50
del . sync ( pathToFile , { force : true } ) ;
43
51
0 commit comments