shadowenv 1.0.3 (new formula)
Closes #39574. Signed-off-by: FX Coudert <fxcoudert@gmail.com>
This commit is contained in:
parent
233463b818
commit
523d6b2478
1 changed files with 46 additions and 0 deletions
46
Formula/shadowenv.rb
Normal file
46
Formula/shadowenv.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
class Shadowenv < Formula
|
||||
desc "Reversible directory-local environment variable manipulations"
|
||||
homepage "https://shopify.github.io/shadowenv/"
|
||||
url "https://github.com/Shopify/shadowenv/archive/1.0.3.tar.gz"
|
||||
sha256 "9b0f25e451b2e47cdacdcb6889aa69bc0a472f5ab337ea7473300cba3b199163"
|
||||
|
||||
depends_on "rust" => :build
|
||||
|
||||
def install
|
||||
system "cargo", "install", "--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
|
Loading…
Reference in a new issue