Skip to content

Commit

Permalink
Skip compression in case of error
Browse files Browse the repository at this point in the history
YUI-Compressor complains too much.
Because compression isn't a crucial step for deployments, we print a
warning and let developers to still deploy and review later the reason
of the problem.
  • Loading branch information
jodosha committed Jan 4, 2016
1 parent 5455111 commit ecdcdce
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
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
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
@@ -0,0 +1 @@
// This empty JavaScript causes an error with YUICompressor

0 comments on commit ecdcdce

Please sign in to comment.