forked from mdn/browser-compat-data
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(husky): add post pull hook to suggest running 'npm install' (mdn…
…#22308) * feat(husky): add post pull hook to suggest running 'npm install' * Rename to save-git-history * update package.json
- Loading branch information
1 parent
7d64b1d
commit 2250802
Showing
5 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env sh | ||
|
||
BRANCH="$(git rev-parse --abbrev-ref HEAD)" | ||
if [ "$BRANCH" != "main" ]; then | ||
exit 0 | ||
fi | ||
|
||
if [ -f ".husky/_/history" ]; then | ||
lastHash=$(cat ./.husky/_/history) | ||
isUpdated=$(git diff $lastHash HEAD -- ./package.json) | ||
if [ "$isUpdated" != "" ]; then | ||
echo "\n⚠🔥 'package.json' has changed. Please run 'npm install'! 🔥" | ||
fi | ||
else | ||
npm install | ||
fi |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* This script stores the 'main' branch's HEAD commit hash in .husky/_/history | ||
* The stored commit hash is used by the post-merge script .husky/post-merge | ||
*/ | ||
|
||
import fs from 'node:fs'; | ||
|
||
import { getBranchName, getHashOfHEAD } from './lib/git.js'; | ||
|
||
const HUSKY_ROOT = '.husky/_/'; | ||
const HISTORY_FILE = HUSKY_ROOT + 'history'; | ||
|
||
if ('main' === getBranchName() && fs.existsSync(HUSKY_ROOT)) { | ||
fs.writeFileSync(HISTORY_FILE, getHashOfHEAD()); | ||
} |