[Dev Ex] Update `cleanup-husky.sh` script for MacOS (#107770)

This commit is contained in:
Sam Jewell 2025-08-05 09:14:32 +01:00 committed by GitHub
parent 47463481b7
commit d562d70ab2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -49,7 +49,16 @@ for hookName in "${oldHuskyHookNames[@]}"; do
echo "Renaming old husky hook $hookPath to $newHookPath" echo "Renaming old husky hook $hookPath to $newHookPath"
fi fi
mv "$hookPath" "$newHookPath" --suffix=old --backup=numbered # Handle backup logic for both macOS (BSD mv) and Linux (GNU mv)
if [[ -f "$newHookPath" ]]; then
# If .old file already exists, create numbered backup
counter=1
while [[ -f "$newHookPath.$counter" ]]; do
counter=$((counter + 1))
done
mv "$newHookPath" "$newHookPath.$counter"
fi
mv "$hookPath" "$newHookPath"
fi fi
fi fi
done done