2023-01-05 08:56:39 +01:00
|
|
|
#!/usr/bin/env sh
|
2024-02-19 11:09:50 +01:00
|
|
|
#!nix-shell -i "bash" -p bash prefetch-npm-deps jq nodejs nix-output-monitor
|
2023-01-05 08:56:39 +01:00
|
|
|
. "$(dirname -- "$0")/_/husky.sh"
|
|
|
|
|
2024-02-19 11:09:50 +01:00
|
|
|
# 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
|
2024-11-17 20:42:23 +01:00
|
|
|
nix run .#nix-update || exit $?
|
2024-02-19 11:09:50 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "You do not appear to have nix installed. Skipping update of nix dependencies."
|
|
|
|
fi
|
|
|
|
|
|
|
|
npx -y lint-staged
|