|
| 1 | +class KeepSorted < Formula |
| 2 | + desc "Language-agnostic formatter that sorts selected lines" |
| 3 | + homepage "https://github.com/google/keep-sorted" |
| 4 | + url "https://github.com/google/keep-sorted/archive/refs/tags/v0.5.0.tar.gz" |
| 5 | + sha256 "8eee061af908fd971911118975e4a2870afff385b3aea9948cc9b221849a9436" |
| 6 | + license "Apache-2.0" |
| 7 | + |
| 8 | + bottle do |
| 9 | + sha256 cellar: :any_skip_relocation, arm64_sequoia: "a7f3c6c8da17ff074bfeb1b8d269cfd57d2ae74136c9c87816b142947f78a615" |
| 10 | + sha256 cellar: :any_skip_relocation, arm64_sonoma: "a7f3c6c8da17ff074bfeb1b8d269cfd57d2ae74136c9c87816b142947f78a615" |
| 11 | + sha256 cellar: :any_skip_relocation, arm64_ventura: "a7f3c6c8da17ff074bfeb1b8d269cfd57d2ae74136c9c87816b142947f78a615" |
| 12 | + sha256 cellar: :any_skip_relocation, sonoma: "3799f06dc1744cf5cfa11131ad06a9dd5a316f661a30bf2432ca1cc191862b6c" |
| 13 | + sha256 cellar: :any_skip_relocation, ventura: "3799f06dc1744cf5cfa11131ad06a9dd5a316f661a30bf2432ca1cc191862b6c" |
| 14 | + sha256 cellar: :any_skip_relocation, x86_64_linux: "b9a7e7b8e8e4c649347212f5d29bec81ea41f1ddd6c3cc4bc68b0538b51cdf8b" |
| 15 | + end |
| 16 | + |
| 17 | + depends_on "go" => :build |
| 18 | + |
| 19 | + def install |
| 20 | + system "go", "build", *std_go_args(ldflags: "-s -w") |
| 21 | + end |
| 22 | + |
| 23 | + test do |
| 24 | + test_file = testpath + "test_input" |
| 25 | + test_file.write <<~EOS |
| 26 | + line will not be touched. |
| 27 | + # keep-sorted start |
| 28 | + line 3 |
| 29 | + line 1 |
| 30 | + line 2 |
| 31 | + # keep-sorted end |
| 32 | + line will also not be touched. |
| 33 | + EOS |
| 34 | + expected = <<~EOS |
| 35 | + line will not be touched. |
| 36 | + # keep-sorted start |
| 37 | + line 1 |
| 38 | + line 2 |
| 39 | + line 3 |
| 40 | + # keep-sorted end |
| 41 | + line will also not be touched. |
| 42 | + EOS |
| 43 | + |
| 44 | + system bin/"keep-sorted", test_file |
| 45 | + assert_equal expected, test_file.read |
| 46 | + end |
| 47 | +end |
0 commit comments