Skip to content

Commit 499a998

Browse files
authored
Merge pull request #81 from JounQin/fix/no_git
fix: skip if no .git root folder found
2 parents d65a692 + b06a48c commit 499a998

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

simple-git-hooks.js

+5
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ function setHooksFromConfig(projectRootPath=process.cwd(), argv=process.argv) {
162162
function _setHook(hook, command, projectRoot=process.cwd()) {
163163
const gitRoot = getGitProjectRoot(projectRoot)
164164

165+
if (!gitRoot) {
166+
console.log('[INFO] No `.git` root folder found, skipping')
167+
return
168+
}
169+
165170
const hookCommand = "#!/bin/sh\n" + command
166171
const hookDirectory = gitRoot + '/hooks/'
167172
const hookPath = path.normalize(hookDirectory + hook)

0 commit comments

Comments
 (0)