Skip to content

Instantly share code, notes, and snippets.

@rogeruiz
Last active September 1, 2021 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogeruiz/ba7a6f85a9d3b7fd53c41054b7b08e61 to your computer and use it in GitHub Desktop.
Save rogeruiz/ba7a6f85a9d3b7fd53c41054b7b08e61 to your computer and use it in GitHub Desktop.
Checking for file changes and running them on the `post-merge` git hook
#!/bin/bash
function changed {
git diff --name-only HEAD@{1} HEAD | grep "^$1" > /dev/null 2>&1
}
if changed 'migrations/'; then
echo "🗄 The migrations/ directory has changed. Run migrations script to get up-to-date."
fi
if changed 'package-lock.json'; then
echo "📦 The package-lock.json file has changed. Run npm install to bring your dependencies up to date."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment