install.js
function getGitFolderPath(currentPath) {
  var git = path.resolve(currentPath, '.git')

  if (!exists(git) || !fs.lstatSync(git).isDirectory()) {
    console.log('pre-commit:');
    console.log('pre-commit: Not found .git folder in', git);
    
    var newPath = path.resolve(currentPath, '..');

    // Stop if we on top folder
    if (currentPath === newPath) {
      return null;
    }

    return getGitFolderPath(newPath);
  }

  console.log('pre-commit:');
  console.log('pre-commit: Found .git folder in', git);
  return git;
}
function getGitFolderPath(currentPath) {
  var git = path.resolve(currentPath, '.git')

  if (!exists(git) || !fs.lstatSync(git).isDirectory()) {
    console.log('pre-commit:');
    console.log('pre-commit: Not found .git folder in', git);
    
    var newPath = path.resolve(currentPath, '..');

    // Stop if we on top folder
    if (currentPath === newPath) {
      return null;
    }

    return getGitFolderPath(newPath);
  }

  console.log('pre-commit:');
  console.log('pre-commit: Found .git folder in', git);
  return git;
}
function getGitFolderPath ( currentPath ) { var git = path . resolve ( currentPath , '.git' ) if ( ! exists ( git ) || ! fs . lstatSync ( git ) . isDirectory ( ) ) { console . log ( 'pre-commit:' ) ; console . log ( 'pre-commit: Not found .git folder in' , git ) ; var newPath = path . resolve ( currentPath , '..' ) ; // Stop if we on top folder if ( currentPath === newPath ) { return null ; } return getGitFolderPath ( newPath ) ; } console . log ( 'pre-commit:' ) ; console . log ( 'pre-commit: Found .git folder in' , git ) ; return git ; }
Function to recursively finding .git folder
Function to recursively finding . git folder