Skip to content

Commit 254245a

Browse files
author
Christopher Frost
committed
Honor an applications env variables
Removing unused code and making the shell command more flexible. The unused in this repo code is required in the downstream tc-Server repo where it is doing the wrong thing. [#90500196]
1 parent 897989c commit 254245a

File tree

3 files changed

+4
-24
lines changed

3 files changed

+4
-24
lines changed

lib/java_buildpack/component/immutable_java_home.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,6 @@ def as_env_var
4242
"JAVA_HOME=#{root}"
4343
end
4444

45-
# Execute a block with the +JAVA_HOME+ environment variable set
46-
#
47-
# @yield yields to block with the +JAVA_HOME+ environment variable set
48-
# @return [Object] the returned value of the block
49-
def do_with
50-
previous_value = ENV['JAVA_HOME']
51-
begin
52-
ENV['JAVA_HOME'] = @delegate.root.cleanpath.to_s
53-
yield
54-
ensure
55-
ENV['JAVA_HOME'] = previous_value
56-
end
57-
end
58-
5945
# @return [String] the root of the droplet's +JAVA_HOME+ formatted as +$PWD/<value>+
6046
def root
6147
qualify_path @delegate.root

lib/java_buildpack/util/shell.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ module Shell
2525

2626
# A +system()+-like command that ensure that the execution fails if the command returns a non-zero exit code
2727
#
28-
# @param [String] command the command to run
28+
# @param [Object] args The command to run
2929
# @return [Void]
30-
def shell(command)
31-
Open3.popen3(command) do |_stdin, stdout, stderr, wait_thr|
30+
def shell(*args)
31+
Open3.popen3(*args) do |_stdin, stdout, stderr, wait_thr|
3232
if wait_thr.value != 0
33-
puts "\nCommand '#{command}' has failed"
33+
puts "\nCommand '#{args.join ' '}' has failed"
3434
puts "STDOUT: #{stdout.gets}"
3535
puts "STDERR: #{stderr.gets}"
3636

spec/java_buildpack/component/immutable_java_home_spec.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@
2727
expect(immutable_java_home.as_env_var).to eq('JAVA_HOME=$PWD/test-java-home')
2828
end
2929

30-
it 'sets JAVA_HOME environment variable' do
31-
immutable_java_home.do_with do
32-
expect(ENV['JAVA_HOME']).to eq('test-java-home')
33-
end
34-
end
35-
3630
it 'returns the qualified delegate root' do
3731
expect(immutable_java_home.root).to eq('$PWD/test-java-home')
3832
end

0 commit comments

Comments
 (0)