From 266622ff6546bc88d450c7ffb5aa94434973d64a Mon Sep 17 00:00:00 2001 From: Sam Moore Date: Wed, 6 Dec 2023 03:49:34 -0500 Subject: [PATCH] chore(pre-commit): ask to run `bun run changeset` If changes to the cli/ directory are committed, suggest adding a changeset. --- .husky/pre-commit | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 6fd7168f..dadf7563 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,20 @@ #!/bin/sh +set -e + bun run lint-staged -git diff-index --cached HEAD | xargs -I{} echo {} +# offer to run `bun run changeset` when changes are committed within the cli/ directory +if git diff-index --cached HEAD | tr '\t' ' ' | sed 's/^.*[ ]//' | grep '^cli/' >/dev/null; then + echo "" + echo "It looks likes you've made changes within the \`cli/\` folder." + printf "Would you like to run \`bun run changeset\` to update the changelog? (Y/n): " + + read res < /dev/tty + case $res in + ""|Y|y) + bun run changeset < /dev/tty + ;; + esac + + echo "" +fi