Kaynağa Gözat

add husky with pre-commit script that check if package.json not changed then restore pnpm-lock.yaml

Mikołaj 6 ay önce
ebeveyn
işleme
60e87c71c9
3 değiştirilmiş dosya ile 27 ekleme ve 0 silme
  1. 16 0
      .husky/pre-commit
  2. 1 0
      package.json
  3. 10 0
      pnpm-lock.yaml

+ 16 - 0
.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

+ 1 - 0
package.json

@@ -31,6 +31,7 @@
     "concurrently": "^9.1.2",
     "concurrently": "^9.1.2",
     "cross-env": "^7.0.3",
     "cross-env": "^7.0.3",
     "glob": "^11.0.1",
     "glob": "^11.0.1",
+    "husky": "^9.1.7",
     "nodemon": "^3.1.9",
     "nodemon": "^3.1.9",
     "pnpm": "10.6.4",
     "pnpm": "10.6.4",
     "postcss": "^8.5.3",
     "postcss": "^8.5.3",

+ 10 - 0
pnpm-lock.yaml

@@ -50,6 +50,9 @@ importers:
       glob:
       glob:
         specifier: ^11.0.1
         specifier: ^11.0.1
         version: 11.0.1
         version: 11.0.1
+      husky:
+        specifier: ^9.1.7
+        version: 9.1.7
       nodemon:
       nodemon:
         specifier: ^3.1.9
         specifier: ^3.1.9
         version: 3.1.9
         version: 3.1.9
@@ -1472,6 +1475,11 @@ packages:
     resolution: {integrity: sha512-3gKm/gCSUipeLsRYZbbdA1BD83lBoWUkZ7G9VFrhWPAU76KwYo5KR8V28bpoPm/ygy0x5/GCbpRQdY7VLYCoIg==}
     resolution: {integrity: sha512-3gKm/gCSUipeLsRYZbbdA1BD83lBoWUkZ7G9VFrhWPAU76KwYo5KR8V28bpoPm/ygy0x5/GCbpRQdY7VLYCoIg==}
     hasBin: true
     hasBin: true
 
 
+  [email protected]:
+    resolution: {integrity: sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==}
+    engines: {node: '>=18'}
+    hasBin: true
+
   [email protected]:
   [email protected]:
     resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==}
     resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==}
     engines: {node: '>=0.10.0'}
     engines: {node: '>=0.10.0'}
@@ -4021,6 +4029,8 @@ snapshots:
 
 
   [email protected]: {}
   [email protected]: {}
 
 
+  [email protected]: {}
+
   [email protected]:
   [email protected]:
     dependencies:
     dependencies:
       safer-buffer: 2.1.2
       safer-buffer: 2.1.2