diff --git a/simple-git-hooks.js b/simple-git-hooks.js index 6ac5e3f..f909846 100644 --- a/simple-git-hooks.js +++ b/simple-git-hooks.js @@ -162,6 +162,11 @@ function setHooksFromConfig(projectRootPath=process.cwd(), argv=process.argv) { function _setHook(hook, command, projectRoot=process.cwd()) { const gitRoot = getGitProjectRoot(projectRoot) + if (!gitRoot) { + console.log('[INFO] No `.git` root folder found, skipping') + return + } + const hookCommand = "#!/bin/sh\n" + command const hookDirectory = gitRoot + '/hooks/' const hookPath = path.normalize(hookDirectory + hook)