Skip to content

Commit

Permalink
Merge pull request #19 from jimmybaker/shut-up-pngquant
Browse files Browse the repository at this point in the history
Added quiet option support for pngquant optimizer
  • Loading branch information
jtescher committed Jan 11, 2018
2 parents 69b6864 + 4671c7a commit 6f6ad70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/image_optimizer/pngquant_optimizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ def perform_optimizations
def command_options
flags = ['--skip-if-larger', '--speed 1',
'--force', '--verbose', '--ext .png']

flags -= ['--verbose'] if quiet?
flags << quantity
flags << path
end
Expand Down
10 changes: 10 additions & 0 deletions spec/image_optimizer/pngquant_optimizer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@
subject
end
end

context 'with quiet parameter' do
let(:options) { { :quiet => true } }

it 'optimizes the png with the quality' do
expected_cmd = "/usr/local/bin/pngquant --skip-if-larger --speed\ 1 --force --ext\ .png --quality\ 100 /path/to/file.png"
expect(pngquant_optimizer).to receive(:system).with(expected_cmd)
subject
end
end
end

context 'optimizing utility is not installed' do
Expand Down

0 comments on commit 6f6ad70

Please sign in to comment.