Skip to content

Commit 5950cd1

Browse files
daeho-robotantony
andcommitted
dart-sass 1.98.0 (new formula)
Update Formula/d/dart-sass.rb Co-authored-by: Anton Melnikov <antonsm21@gmail.com>
1 parent 9d41ec8 commit 5950cd1

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

Formula/d/dart-sass.rb

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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.98.0.tar.gz"
5+
sha256 "2eab6aebaba4e095e67b970baf8b0bdb4b934be17fdee1ca5d5da6a490b5517a"
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+
ENV["PUB_ENVIRONMENT"] = "homebrew:sass"
18+
ENV["DART_SUPPRESS_ANALYTICS"] = "true"
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+
args = %W[
28+
-Dversion=#{version}
29+
-Ddart-vesrion=#{Formula["dart-sdk"].version}
30+
-Dcompiler-version=#{version}
31+
-Dprotocol-version=#{resource("language").version}
32+
]
33+
if OS.mac?
34+
system "dart", "compile", "exe", "--output", "sass", *args, "bin/sass.dart"
35+
bin.install "sass"
36+
else
37+
system "dart", "compile", "aot-snapshot", "--output", "sass.aot", *args, "bin/sass.dart"
38+
libexec.install "sass.aot"
39+
# Dart creates elf binary with inner elf binary on linux and it breaks during the bottle creation
40+
# So, here we copy `dartaotruntime` binary to run the compiled aot snapshot
41+
cp Formula["dart-sdk"].opt_libexec/"bin/dartaotruntime", libexec
42+
43+
(bin/"sass").write <<~BASH
44+
#!/bin/bash
45+
exec "#{libexec}/dartaotruntime" "#{libexec}/sass.aot" "$@"
46+
BASH
47+
end
48+
end
49+
50+
test do
51+
assert_match version.to_s, shell_output("#{bin}/sass --version")
52+
53+
(testpath/"test.scss").write(".class {property: 1 + 1}")
54+
assert_match "property: 2;", shell_output("#{bin}/sass test.scss 2>&1")
55+
56+
(testpath/"input.scss").write <<~EOS
57+
div {
58+
img {
59+
border: 0px;
60+
}
61+
}
62+
EOS
63+
64+
assert_equal "div img{border:0px}",
65+
shell_output("#{bin}/sass --style compressed input.scss").strip
66+
end
67+
end

0 commit comments

Comments
 (0)