Skip to content

Instantly share code, notes, and snippets.

@gsmendoza
gsmendoza / pre-commit
Created October 5, 2013 07:13
Git pre-commit hook for image optimization.
#!/usr/bin/env ruby
require 'image_optim'
staged_files = `git diff --cached --name-only --diff-filter=ACM`.split("\n")
staged_files.select! { |f| f =~ %r{/images/} }
if staged_files.any?
image_optim = ImageOptim.new(pngout: false)