summary refs log tree commit diff
path: root/.husky
diff options
context:
space:
mode:
authorRory& <myrainbowdash949@gmail.com>2024-02-19 10:09:50 +0000
committerGitHub <noreply@github.com>2024-02-19 21:09:50 +1100
commit29df169c81d963742cc973a8835a7c1a126d7220 (patch)
tree7db8092c20e187ff812f8b9f71b28c5c25641d56 /.husky
parentFix application icons (#1110) (diff)
downloadserver-29df169c81d963742cc973a8835a7c1a126d7220.tar.xz
Add nix flake to repo (#1111)
Diffstat (limited to '.husky')
-rwxr-xr-x.husky/pre-commit26
1 files changed, 25 insertions, 1 deletions
diff --git a/.husky/pre-commit b/.husky/pre-commit
index 1bc5a8c6..702231b5 100755
--- a/.husky/pre-commit
+++ b/.husky/pre-commit
@@ -1,4 +1,28 @@
 #!/usr/bin/env sh
+#!nix-shell -i "bash" -p bash prefetch-npm-deps jq nodejs nix-output-monitor
 . "$(dirname -- "$0")/_/husky.sh"
 
-npx -y lint-staged
\ No newline at end of file
+# Check if nix is available
+if [ -x "$(/usr/bin/env which nix-shell 2>/dev/null)" ]; then
+  # Check if we haven't re-executed ourselves yet
+  if [ ! "$HOOK_NIX_SHELL" ]; then
+    echo "Nix is available, updating nix flake..."
+    export HOOK_NIX_SHELL=1
+    nix-shell $0
+    exit $?
+  else
+    nix flake update
+    # run ./nix-update.sh if package lock has changed and has no unstaged changes
+    if [ -n "$(git status --porcelain=v1 2>/dev/null | grep -E '^(MM| M) package-lock.json')" ]; then
+      echo "package-lock.json has unstaged changes. Skipping update of nix dependencies."
+    elif [ ! -n "$(git status --porcelain=v1 2>/dev/null | grep -E '^M package-lock.json')" ]; then
+      echo "package-lock.json has no changes. Skipping update of nix dependencies."
+    else
+      ./nix-update.sh || exit $?
+    fi
+  fi
+else
+  echo "You do not appear to have nix installed. Skipping update of nix dependencies."
+fi
+
+npx -y lint-staged