diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 000000000..cb5dcf64c --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,16 @@ +#!/bin/sh + +if git diff --quiet --cached package.json; then + if git diff --quiet --cached pnpm-lock.yaml; then + echo "pnpm-lock.yaml not changed, nothing to do." + else + echo "pnpm-lock.yaml changed, restore..." + git restore --staged pnpm-lock.yaml + git checkout pnpm-lock.yaml + echo "Restored pnpm-lock.yaml." + fi +else + echo "package.json changed, pnpm-lock.yaml change" +fi + +exit 0 diff --git a/package.json b/package.json index 9aca548a4..a75319d42 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "concurrently": "^9.1.2", "cross-env": "^7.0.3", "glob": "^11.0.1", + "husky": "^9.1.7", "nodemon": "^3.1.9", "pnpm": "10.6.4", "postcss": "^8.5.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b61a08ec8..d4fd69a5a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -50,6 +50,9 @@ importers: glob: specifier: ^11.0.1 version: 11.0.1 + husky: + specifier: ^9.1.7 + version: 9.1.7 nodemon: specifier: ^3.1.9 version: 3.1.9 @@ -1472,6 +1475,11 @@ packages: resolution: {integrity: sha512-3gKm/gCSUipeLsRYZbbdA1BD83lBoWUkZ7G9VFrhWPAU76KwYo5KR8V28bpoPm/ygy0x5/GCbpRQdY7VLYCoIg==} hasBin: true + husky@9.1.7: + resolution: {integrity: sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==} + engines: {node: '>=18'} + hasBin: true + iconv-lite@0.4.24: resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} engines: {node: '>=0.10.0'} @@ -4021,6 +4029,8 @@ snapshots: human-id@4.1.1: {} + husky@9.1.7: {} + iconv-lite@0.4.24: dependencies: safer-buffer: 2.1.2