From 729a5498bce9a73080e4fcfea2fb235f52eaced4 Mon Sep 17 00:00:00 2001 From: Craigory Coppola Date: Fri, 12 May 2023 18:30:39 -0400 Subject: [PATCH] chore(repo): setup hook to notify on package lock changes (#16972) --- .husky/post-checkout | 3 +++ .husky/post-merge | 3 +++ scripts/notify-lockfile-changes.js | 9 +++++++++ 3 files changed, 15 insertions(+) create mode 100755 .husky/post-checkout create mode 100755 .husky/post-merge create mode 100644 scripts/notify-lockfile-changes.js diff --git a/.husky/post-checkout b/.husky/post-checkout new file mode 100755 index 0000000000000..a2eaf794b9870 --- /dev/null +++ b/.husky/post-checkout @@ -0,0 +1,3 @@ +#!/bin/sh +changedFiles="$(git diff-tree -r --name-only --no-commit-id $1 $2)" +node ./scripts/notify-lockfile-changes.js $changedFiles \ No newline at end of file diff --git a/.husky/post-merge b/.husky/post-merge new file mode 100755 index 0000000000000..8e7913dbdc744 --- /dev/null +++ b/.husky/post-merge @@ -0,0 +1,3 @@ +#!/bin/sh +changedFiles="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)" +node ./scripts/notify-lockfile-changes.js $changedFiles \ No newline at end of file diff --git a/scripts/notify-lockfile-changes.js b/scripts/notify-lockfile-changes.js new file mode 100644 index 0000000000000..1cb60472924fa --- /dev/null +++ b/scripts/notify-lockfile-changes.js @@ -0,0 +1,9 @@ +if (process.argv.slice(2).some((arg) => arg.includes('pnpm-lock.yaml'))) { + console.warn( + [ + '⚠️ ----------------------------------------------------------------------------------------- ⚠️', + '⚠️ pnpm-lock.yaml changed, please run `pnpm install` to ensure your packages are up to date. ⚠️', + '⚠️ ----------------------------------------------------------------------------------------- ⚠️', + ].join('\n') + ); +}