-2

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..

Laxman
  • 21
  • 3
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Nov 20 '22 at 13:18

1 Answers1

-1

#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

Laxman
  • 21
  • 3
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 23 '22 at 03:15