if you want when developer changed one file of the project and you want to force to make relevant changes in to another "similar " file with the help of husky and shellScript..
#Inside of pre-commit hook put the following code
#!/usr/bin/env sh
. "$(dirname "$0")/_/husky.sh"
FILES=$(git diff --cached --name-only --diff-filter=ACMR )
myarray=($FILES)
file1="src/App.css"
file2="src/App.jsx"
echo ${myarray[@]}
if [[ " ${myarray[*]} " =~ " ${file1} " ]]
then
if [[ " ${myarray[*]} " =~ " ${file2} " ]]
then
echo "both file are present you can continue to commit"
else
echo need to change src/App.jsx file also
exit 1
fi
else `enter code here`
echo "file does not exist you can continue"
fi
# npm test
npx lint-staged
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.