homebrew-core/Formula/closure-compiler.rb

37 lines
1.1 KiB
Ruby

class ClosureCompiler < Formula
desc "JavaScript optimizing compiler"
homepage "https://developers.google.com/closure/compiler"
url "https://search.maven.org/remotecontent?filepath=com/google/javascript/closure-compiler/v20220202/closure-compiler-v20220202.jar"
sha256 "23d91c2bda0be80312b48ede19faee27e09842e02c56c8b14f3921d09589af0f"
license "Apache-2.0"
livecheck do
url "https://search.maven.org/remotecontent?filepath=com/google/javascript/closure-compiler/"
regex(/href=.*?v?(\d{8})/i)
end
bottle do
sha256 cellar: :any_skip_relocation, all: "0fc3822a9e9e5bf8bb9b493f969867413ef864b44b0109ee5dd10647ace10316"
end
depends_on "openjdk"
def install
libexec.install Dir["*"]
bin.write_jar_script libexec/"closure-compiler-v#{version}.jar", "closure-compiler"
end
test do
(testpath/"test.js").write <<~EOS
(function(){
var t = true;
return t;
})();
EOS
system bin/"closure-compiler",
"--js", testpath/"test.js",
"--js_output_file", testpath/"out.js"
assert_equal (testpath/"out.js").read.chomp, "(function(){return!0})();"
end
end