Skip to content

Commit

Permalink
stuffbin: add 1.1.0 bottle.
Browse files Browse the repository at this point in the history
  • Loading branch information
gromgit committed Jan 19, 2023
1 parent 6785dd3 commit c6c2648
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions Formula/stuffbin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
class Stuffbin < Formula
desc "Compress and embed static files and assets into Go binaries"
homepage "https://github.com/knadh/stuffbin"
url "https://github.com/knadh/stuffbin/archive/refs/tags/v1.1.0.tar.gz"
sha256 "7a96e189108d3c5ba437e2d40484cfd4145fd1b6e3d84a798c14197c2a35e3e0"
license "MIT"
head "https://github.com/knadh/stuffbin.git", branch: "master"

bottle do
root_url "https://github.com/gromgit/homebrew-core-mojave/releases/download/stuffbin"
sha256 cellar: :any_skip_relocation, mojave: "ae078f113c34cb50413b87fd9bfa69820e94223ba79e8d48c59243a616ea92be"
end

depends_on "go" => [:build, :test]

def install
system "go", "build", *std_go_args(ldflags: "-s -w"), "./stuffbin"
end

test do
mkdir "brewtest" do
system "go", "mod", "init", "brewtest"
system "go", "get", "github.com/knadh/stuffbin"

(testpath/"brewtest/foo.txt").write "brewfoo"
(testpath/"brewtest/main.go").write <<~EOS
package main
import (
"log"
"os"
"github.com/knadh/stuffbin"
)
func main() {
path, _ := os.Executable()
fs, _ := stuffbin.UnStuff(path)
f, _ := fs.Get("foo.txt")
log.Println("foo.txt =", string(f.ReadBytes()))
}
EOS

system "go", "build", "."
output = shell_output("#{bin}/stuffbin -a stuff -in brewtest -out brewtest2 foo.txt")
assert_match "stuffing complete.", output
assert_match "foo.txt = brewfoo", shell_output("#{testpath}/brewtest/brewtest2 2>&1")

output = shell_output("#{bin}/stuffbin -a id -in brewtest2")
assert_match "brewtest2: stuffbin", output
assert_match "/foo.txt", output
end
end
end

0 comments on commit c6c2648

Please sign in to comment.