-
Notifications
You must be signed in to change notification settings - Fork 1
/
hof.rb
42 lines (34 loc) · 1.84 KB
/
hof.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class Hof < Formula
desc "Flexible data modeling & code generation system"
homepage "https://hofstadter.io/"
version "0.6.6"
url "https://github.com/hofstadter-io/hof.git",
tag: "v0.6.6",
revision: "0f49b4d71a66788b006daacf905a2b138768beca"
license "BSD-3-Clause"
head "https://github.com/hofstadter-io/hof.git", branch: "_dev"
depends_on "go" => :build
depends_on "docker" => :test
def install
arch = Hardware::CPU.intel? ? "amd64" : Hardware::CPU.arch.to_s
os = OS.kernel_name.downcase
ldflags = %W[ -s -w -X github.com/hofstadter-io/hof/cmd/hof/verinfo.Version=#{version} -X github.com/hofstadter-io/hof/cmd/hof/verinfo.Commit=#{Utils.git_head} -X github.com/hofstadter-io/hof/cmd/hof/verinfo.BuildDate=#{time.iso8601} -X github.com/hofstadter-io/hof/cmd/hof/verinfo.GoVersion=#{Formula["go"].version} -X github.com/hofstadter-io/hof/cmd/hof/verinfo.BuildOS=#{os} -X github.com/hofstadter-io/hof/cmd/hof/verinfo.BuildArch=#{arch} ]
ENV["CGO_ENABLED"] = "0"
ENV["HOF_TELEMETRY_DISABLED"] = 1
system "go", "build", *std_go_args(ldflags: ldflags), "./cmd/hof"
bash_output = Utils.safe_popen_read(bin/"hof", "completion", "bash")
(bash_completion/"hof").write bash_output
zsh_output = Utils.safe_popen_read(bin/"hof", "completion", "zsh")
(zsh_completion/"_hof").write zsh_output
fish_output = Utils.safe_popen_read(bin/"hof", "completion", "fish")
(fish_completion/"hof.fish").write fish_output
end
test do
ENV["HOF_TELEMETRY_DISABLED"] = 1
assert_match "v#{version}", shell_output("#{bin}/hof version")
system bin/"hof", "mod", "init", "cue", "brew.sh/brewtest"
assert_predicate testpath/"cue.mods", :exist?
assert_equal "module: \"brew.sh/brewtest\"", (testpath/"cue.mod/module.cue").read.chomp
assert_match version.to_s, shell_output(bin/"hof version")
end
end