-
Notifications
You must be signed in to change notification settings - Fork 7
/
pkgx.rb
56 lines (45 loc) · 1.84 KB
/
pkgx.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
class Pkgx < Formula
desc "Run Anything"
homepage "https://pkgx.sh"
url "https://github.com/pkgxdev/pkgx/releases/download/v1.3.1/pkgx-1.3.1.tar.xz"
sha256 "7c735d2b3288b823e802d8e2506142f9887ad63d9c08dfdb252ffb5eec289e2c"
license "Apache-2.0"
livecheck do
url :stable
strategy :github_latest
end
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "1d5fd603574631d07a21fca5c56472e5787b7956169ebae17b82ff5f3cb184f9"
sha256 cellar: :any_skip_relocation, big_sur: "b8655d328fbb532b5b70894d4b47382698bae6f16ae6d733f04ac76931c43a7f"
# Linux bottles fail currently: patchelf breaks deno compiled binaries.
# https://github.com/pkgxdev/brewkit/blob/main/share/brewkit/fix-elf.ts#L38-L42
# and it's not possible to skip relocation in linuxbrew:
# https://github.com/Homebrew/brew/blob/d1f60aea49d35fc0ba8f02a1f4fd26d0a369e071/Library/Homebrew/extend/os/linux/software_spec.rb
#sha256 cellar: :any_skip_relocation, x86_64_linux: "3496e8f20c8096cba2f05c5592f56104fa9e71b82d57e3220855373dcb352ee9"
root_url "https://github.com/pkgxdev/homebrew-made/releases/download/v1.3.1"
end
depends_on "deno" => :build
depends_on "unzip" => :build # deno >=1.39.1 uses unzip when remote-fetching their compilable runtime
def install
system "deno", "task", "compile"
bin.install "pkgx"
end
def caveats
<<~EOS
try it out:
pkgx node@18 --eval 'console.log("pkgx: run anything")'
shell integration:
pkgx integrate --dry-run
# ^^ https://docs.pkgx.sh/shell-integration
EOS
end
test do
(testpath/"hello.js").write <<~EOS
const middle="llo, w"
console.log(`he${middle}orld`);
EOS
with_env("PKGX_DIR" => testpath/".pkgx") do
assert_equal "hello, world", shell_output("#{bin}/pkgx '#{testpath}/hello.js'").chomp
end
end
end