Skip to content

Commit

Permalink
Merge pull request #81 from JounQin/fix/no_git
Browse files Browse the repository at this point in the history
fix: skip if no .git root folder found
  • Loading branch information
toplenboren committed Oct 17, 2022
2 parents d65a692 + b06a48c commit 499a998
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions simple-git-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 499a998

Please sign in to comment.