Skip to content

Commit

Permalink
Merge pull request #32 from lotus/skip-compression-in-case-of-error
Browse files Browse the repository at this point in the history
Skip compression of an asset in case of error during deploy
  • Loading branch information
jodosha committed Jan 4, 2016
2 parents 5455111 + ecdcdce commit 83e0d2f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/lotus/assets/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ def store_manifest(asset, target)
# @api private
def _compress(compressor, asset)
_write(asset, compressor.compress(::File.read(asset)))
rescue => e
warn "Skipping compression of: `#{ asset }'\n\nReason: #{ e }"
end

# @since x.x.x
Expand Down
10 changes: 10 additions & 0 deletions test/bundler_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@
manifest.must_be :exist?
end

describe "in case of error" do
let(:dest) { TMP.join('broken', 'public') }
let(:source) { __dir__ + '/fixtures/broken/public/assets' }

it "prints the name of the asset that caused the problem" do
_, err = capture_subprocess_io { run! }
err.must_match "Skipping compression of:"
end
end

private

def run!
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/broken/public/assets/broken.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// This empty JavaScript causes an error with YUICompressor

0 comments on commit 83e0d2f

Please sign in to comment.