From 5dcabd67a1215b6061e15c72f6db000d3b3387c0 Mon Sep 17 00:00:00 2001 From: sqlwwx Date: Thu, 24 May 2018 10:03:00 +0800 Subject: [PATCH 1/4] log --- install.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/install.js b/install.js index e24fc0d..3017f99 100644 --- a/install.js +++ b/install.js @@ -17,16 +17,20 @@ var fs = require('fs') // to work correctly. // +console.log('pre-commit: root ', root) + var git = getGitFolderPath(root); // Function to recursively finding .git folder function getGitFolderPath(currentPath) { var git = path.resolve(currentPath, '.git') - if (!exists(git) || !fs.lstatSync(git).isDirectory()) { + var isExists = exists(git) + var isDirectory = fs.lstatSync(git).isDirectory() + if (!isExists || !isDirectory) { console.log('pre-commit:'); - console.log('pre-commit: Not found .git folder in', git); - + console.log('pre-commit: Not found .git folder in', git, isExists, isDirectory); + var newPath = path.resolve(currentPath, '..'); // Stop if we on top folder From 49d1c04366aba18a5b8e618b7ded6c80068d1b76 Mon Sep 17 00:00:00 2001 From: sqlwwx Date: Thu, 24 May 2018 22:10:57 +0800 Subject: [PATCH 2/4] Update install.js --- install.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.js b/install.js index 3017f99..7afdc60 100644 --- a/install.js +++ b/install.js @@ -48,7 +48,7 @@ function getGitFolderPath(currentPath) { // // Resolve git directory for submodules -// +console.log(git, exists(git), fs.lstatSync(git).isFile()); if (exists(git) && fs.lstatSync(git).isFile()) { var gitinfo = fs.readFileSync(git).toString() , gitdirmatch = /gitdir: (.+)/.exec(gitinfo) From df636fcd9bdccc88edd0e06dd9460f355632cb5c Mon Sep 17 00:00:00 2001 From: sqlwwx Date: Thu, 24 May 2018 22:16:37 +0800 Subject: [PATCH 3/4] Update install.js --- install.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.js b/install.js index 7afdc60..e5aceca 100644 --- a/install.js +++ b/install.js @@ -26,7 +26,7 @@ function getGitFolderPath(currentPath) { var git = path.resolve(currentPath, '.git') var isExists = exists(git) - var isDirectory = fs.lstatSync(git).isDirectory() + var isDirectory = isExists && fs.lstatSync(git).isDirectory() if (!isExists || !isDirectory) { console.log('pre-commit:'); console.log('pre-commit: Not found .git folder in', git, isExists, isDirectory); From 776c634aac0bcbf76995ab165dfefc1db125e706 Mon Sep 17 00:00:00 2001 From: sqlwwx Date: Thu, 24 May 2018 22:18:56 +0800 Subject: [PATCH 4/4] Update install.js --- install.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install.js b/install.js index e5aceca..437033c 100644 --- a/install.js +++ b/install.js @@ -27,6 +27,9 @@ function getGitFolderPath(currentPath) { var isExists = exists(git) var isDirectory = isExists && fs.lstatSync(git).isDirectory() + if (isExists && !isDirectory) { + return git + } if (!isExists || !isDirectory) { console.log('pre-commit:'); console.log('pre-commit: Not found .git folder in', git, isExists, isDirectory);