Last active
August 29, 2015 13:57
-
-
Save royaldark/9538212 to your computer and use it in GitHub Desktop.
post-checkout git hook: Run `npm install` if package.json has changed
This file contains hidden or 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
#!/usr/bin/env ruby | |
from_commit, to_commit, checkout_type = ARGV | |
# If type is 0, this is a single-file checkout; abort. | |
if checkout_type.to_i == 0 | |
exit 0 | |
end | |
files_changed = `git diff --name-only #{from_commit} #{to_commit}` | |
if files_changed.include? 'package.json' | |
puts "\npackage.json changed. Running npm install.\n\n" | |
exec 'npm install' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment