Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FILES env variable #114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion simple-git-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,20 @@ if [ "$SKIP_SIMPLE_GIT_HOOKS" = "1" ]; then
exit 0
fi

FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')

if [ -f "$SIMPLE_GIT_HOOKS_RC" ]; then
. "$SIMPLE_GIT_HOOKS_RC"
fi

`

const APPEND_SCRIPT =
`

echo "$FILES" | xargs git add
`

/**
* Recursively gets the .git folder path from provided directory
* @param {string} directory
Expand Down Expand Up @@ -192,7 +200,7 @@ function _setHook(hook, command, projectRoot=process.cwd()) {
return
}

const hookCommand = PREPEND_SCRIPT + command
const hookCommand = PREPEND_SCRIPT + command + APPEND_SCRIPT
const hookDirectory = gitRoot + '/hooks/'
const hookPath = path.normalize(hookDirectory + hook)

Expand Down