diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index 7b47f21658..ea6d0da2c4 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -116,9 +116,21 @@ def gzip(path) end # different brotli versions use different parameters -def brotli_command(path, max_compress) - compression_quality = max_compress ? "11" : "6" - "brotli -f --quality=#{compression_quality} #{path} --output=#{path}.br" +ver_out, _ver_err, ver_status = Open3.capture3('brotli --version') +if !ver_status.success? + # old versions of brotli don't respond to --version + def brotli_command(path, max_compress) + compression_quality = max_compress ? "11" : "6" + "brotli --quality 11 --input #{path} --output #{path}.br" + end +elsif ver_out >= "brotli 1.0.0" + def brotli_command(path, max_compress) + compression_quality = max_compress ? "11" : "6" + "brotli -f --quality=11 #{path} --output=#{path}.br" + end +else + # not sure what to do here, not expecting this + raise "cannot determine brotli version" end def brotli(path, max_compress)