From 33f5a36a28bc077644a0a590f229b2e2edabbadb Mon Sep 17 00:00:00 2001 From: Nikos Vasilakis Date: Sun, 5 Jul 2020 15:47:00 -0400 Subject: [PATCH] Get top-level path from git itself --- install.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/install.js b/install.js index e24fc0d..d577ee8 100644 --- a/install.js +++ b/install.js @@ -8,8 +8,11 @@ var fs = require('fs') , os = require('os') , hook = path.join(__dirname, 'hook') , root = path.resolve(__dirname, '..', '..') + , spawn = require('child_process').spawnSync + , tl = spawn('git', ['rev-parse', '--show-toplevel']).stdout.toString().trim() , exists = fs.existsSync || path.existsSync; + // // Gather the location of the possible hidden .git directory, the hooks // directory which contains all git hooks and the absolute location of the @@ -27,7 +30,7 @@ function getGitFolderPath(currentPath) { console.log('pre-commit:'); console.log('pre-commit: Not found .git folder in', git); - var newPath = path.resolve(currentPath, '..'); + var newPath = tl || path.resolve(currentPath, '..'); // Stop if we on top folder if (currentPath === newPath) {