Skip to content

Instantly share code, notes, and snippets.

@royaldark
Last active August 29, 2015 13:57
Show Gist options
  • Save royaldark/9538212 to your computer and use it in GitHub Desktop.
Save royaldark/9538212 to your computer and use it in GitHub Desktop.
post-checkout git hook: Run `npm install` if package.json has changed
#!/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