|
| 1 | +class DartSass < Formula |
| 2 | + desc "Reference implementation of Sass, written in Dart" |
| 3 | + homepage "https://sass-lang.com/dart-sass" |
| 4 | + url "https://github.com/sass/dart-sass/archive/refs/tags/1.97.3.tar.gz" |
| 5 | + sha256 "22ea1f689060edf10ee533047f553ad1c558209ea642687998f4ccb465faa9fc" |
| 6 | + license "MIT" |
| 7 | + |
| 8 | + depends_on "buf" => :build |
| 9 | + depends_on "dart-sdk" => :build |
| 10 | + |
| 11 | + resource "language" do |
| 12 | + url "https://github.com/sass/sass/archive/refs/tags/embedded-protocol-3.2.0.tar.gz" |
| 13 | + sha256 "4e1f81684bc1666f03e52ddc790d0c2c22d99a5313fa2efe1dde4a5b5733c186" |
| 14 | + end |
| 15 | + |
| 16 | + def install |
| 17 | + # Tell the pub server where these installations are coming from. |
| 18 | + ENV["PUB_ENVIRONMENT"] = "homebrew:sass" |
| 19 | + |
| 20 | + (buildpath/"build/language").install resource("language") |
| 21 | + |
| 22 | + system "dart", "pub", "get" |
| 23 | + with_env(UPDATE_SASS_PROTOCOL: "false") do |
| 24 | + system "dart", "run", "grinder", "protobuf" |
| 25 | + end |
| 26 | + |
| 27 | + system "dart", "compile", "exe", |
| 28 | + "-Dversion=#{version}", |
| 29 | + "-Dcompiler-version=#{version}", |
| 30 | + "-Dprotocol-version=#{resource("language").version}", |
| 31 | + "bin/sass.dart", |
| 32 | + "--output", "sass" |
| 33 | + bin.install "sass" |
| 34 | + end |
| 35 | + |
| 36 | + test do |
| 37 | + assert_match version.to_s, shell_output("#{bin}/sass --version") if OS.mac? |
| 38 | + |
| 39 | + (testpath/"test.scss").write(".class {property: 1 + 1}") |
| 40 | + assert_match "property: 2;", shell_output("#{bin}/sass test.scss 2>&1") |
| 41 | + |
| 42 | + (testpath/"input.scss").write <<~EOS |
| 43 | + div { |
| 44 | + img { |
| 45 | + border: 0px; |
| 46 | + } |
| 47 | + } |
| 48 | + EOS |
| 49 | + |
| 50 | + assert_equal "div img{border:0px}", |
| 51 | + shell_output("#{bin}/sass --style compressed input.scss").strip |
| 52 | + end |
| 53 | +end |
0 commit comments