Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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