diff --git a/simple-git-hooks.js b/simple-git-hooks.js index c57f8c4..9615c7c 100644 --- a/simple-git-hooks.js +++ b/simple-git-hooks.js @@ -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 @@ -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)