diff --git a/Formula/dufs.rb b/Formula/dufs.rb new file mode 100644 index 00000000000..4a2faf15230 --- /dev/null +++ b/Formula/dufs.rb @@ -0,0 +1,37 @@ +class Dufs < Formula + desc "Static file server" + homepage "https://github.com/sigoden/dufs" + url "https://github.com/sigoden/dufs/archive/refs/tags/v0.31.0.tar.gz" + sha256 "f5078fb245d0aeccbcfe966a0aa89fb2ee5af7a88016534ab66776971c0c3d2e" + license any_of: ["Apache-2.0", "MIT"] + + bottle do + root_url "https://github.com/gromgit/homebrew-core-mojave/releases/download/dufs" + sha256 cellar: :any_skip_relocation, mojave: "fbe921871e3e28e49067c5ad570d0fed66fce2abc0dc67329c920ebd6827af9d" + end + + depends_on "rust" => :build + + def install + system "cargo", "install", *std_cargo_args + + generate_completions_from_executable(bin/"dufs", "--completions") + end + + test do + port = free_port + pid = fork do + exec "#{bin}/dufs", bin.to_s, "-b", "127.0.0.1", "--port", port.to_s + end + + sleep 2 + + begin + read = (bin/"dufs").read + assert_equal read, shell_output("curl localhost:#{port}/dufs") + ensure + Process.kill("SIGINT", pid) + Process.wait(pid) + end + end +end