Fix post-merge.sh exit status in some cases

This commit tweaks the function runOnChange() to make sure it always
returns the correct exit status. Before this change, this function would
return 1 instead of 0 when there was no change to composer.lock and
package-lock.json in the commits that were merged. This resulted in
husky mistakenly reporting a failure when actually the post-merge script
succeeded.
This commit is contained in:
Rodrigo Primo 2020-09-18 15:36:04 -03:00
parent d99053dbed
commit ac4c057740
1 changed files with 4 additions and 1 deletions

View File

@ -3,7 +3,10 @@
changedFiles="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)" changedFiles="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
runOnChange() { runOnChange() {
echo "$changedFiles" | grep -q "$1" && eval "$2" if echo "$changedFiles" | grep -q "$1"
then
eval "$2"
fi
} }
runOnChange "package-lock.json" "npm install" runOnChange "package-lock.json" "npm install"