diff --git a/install.js b/install.js index e24fc0d..437033c 100644 --- a/install.js +++ b/install.js @@ -17,16 +17,23 @@ 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 = 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); - + console.log('pre-commit: Not found .git folder in', git, isExists, isDirectory); + var newPath = path.resolve(currentPath, '..'); // Stop if we on top folder @@ -44,7 +51,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)