Achieve this behaviour with the "skip" option #463
Answered
by
mrexox
PointSingularity
asked this question in
Q&A
-
I am migrating from lint-staged/husky, and I am on Windows. I have this post-merge hook defined: #!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
IFS=$'\n'
PACKAGE_LOCK_REGEX="(^packages\/.*\/package-lock\.json)|(^package-lock\.json)"
PACKAGES=("$(git diff --name-only HEAD@{1} HEAD | grep -E "$PACKAGE_LOCK_REGEX")")
# If there are any package-lock.json files, run npm install in the directory of the package-lock.json file
if [[ ${PACKAGES[@]} ]]; then
for package in $PACKAGES; do
echo "📦 $package was changed. Running npm install. "
DIR=$(dirname package)
cd "$DIR" && npm install
done
fi Is it possible to achieve this behavior in lefthook using the skip option. post-merge:
commands:
run-install:
skip: |
PACKAGE_LOCK_REGEX="(^packages\/.*\/package-lock\.json)|(^package-lock\.json)"
PACKAGES=("$(git diff --name-only HEAD@{1} HEAD | grep -E "$PACKAGE_LOCK_REGEX")")
if [[ ${PACKAGES[@]} ]]; then
return 0
else
return 1
fi
run: npm install |
Beta Was this translation helpful? Give feedback.
Answered by
mrexox
Apr 4, 2023
Replies: 1 comment 10 replies
-
Hey! There is a
# lefthook.yml
post-merge:
commands:
run-install:
files: git diff --name-only HEAD@{1} HEAD | grep -E "(^packages\/.*\/package-lock\.json)|(^package-lock\.json)"
run: npm install |
Beta Was this translation helpful? Give feedback.
10 replies
Answer selected by
PointSingularity
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey! There is a
files
option that allows to skip execution if the result offiles
is empty. I think it can fit your case: