Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
53 lines (48 sloc) 1.98 KB
class Shadowenv < Formula
desc "Reversible directory-local environment variable manipulations"
homepage "https://shopify.github.io/shadowenv/"
url "https://github.com/Shopify/shadowenv/archive/1.3.0.tar.gz"
sha256 "e5b202f75234f47ea8ca94331192223c28877021f978a6ed39e50927b2381e06"
bottle do
cellar :any_skip_relocation
sha256 "1a016af9b61eb34448862c31aec95703fdd4fff1fcd219cf1674edc7f6cd44d8" => :catalina
sha256 "b24c917bb47805a2253f87878da85d2dbfb3bbe34b968cb773953e04efdc6cbc" => :mojave
sha256 "47635809fcac1223b736bf2ad9a4a5065595f92bc6a7c240dc16ead2475de188" => :high_sierra
end
depends_on "rust" => :build
def install
system "cargo", "install", "--locked", "--root", prefix, "--path", "."
man1.install "#{buildpath}/man/man1/shadowenv.1"
man5.install "#{buildpath}/man/man5/shadowlisp.5"
end
test do
expected_output = <<~EOM
EXAMPLE:
EXAMPLE2:b
EXAMPLE3:b
EXAMPLE_PATH:a:b:d
---
EXAMPLE:a
EXAMPLE2:
EXAMPLE3:a
EXAMPLE_PATH:c:d
EOM
environment = "export EXAMPLE2=b EXAMPLE3=b EXAMPLE_PATH=a:b:d;"
hash = "1256a7c3de15e864"
data = {
"scalars" => [
{ "name" => "EXAMPLE2", "original" => nil, "current" => "b" },
{ "name" => "EXAMPLE", "original" => "a", "current" => nil },
{ "name" => "EXAMPLE3", "original" => "a", "current" => "b" },
],
"lists" => [
{ "name" => "EXAMPLE_PATH", "additions" => ["b", "a"], "deletions" => ["c"] },
],
}
# Read ...'\"'\"'... on the next line as a ruby `...' + "'" + '...` but for bash
shadowenv_command = "#{bin}/shadowenv hook '\"'\"'#{hash}:#{data.to_json}'\"'\"' 2> /dev/null"
print_vars = "echo EXAMPLE:$EXAMPLE; echo EXAMPLE2:$EXAMPLE2; echo EXAMPLE3:$EXAMPLE3; echo EXAMPLE_PATH:$EXAMPLE_PATH;"
actual_output = shell_output("bash -c '#{environment} #{print_vars} echo ---; eval \"$(#{shadowenv_command})\"; #{print_vars}'")
assert_equal expected_output, actual_output
end
end
You can’t perform that action at this time.