Commit e7ec75ee authored by Marius Rackwitz's avatar Marius Rackwitz

[PodSourcePreparer] Don't leak version var on failure

parent eb142cb2
...@@ -58,12 +58,15 @@ module Pod ...@@ -58,12 +58,15 @@ module Pod
return unless spec.prepare_command return unless spec.prepare_command
UI.section(' > Running prepare command', '', 1) do UI.section(' > Running prepare command', '', 1) do
Dir.chdir(path) do Dir.chdir(path) do
ENV.delete('CDPATH') begin
ENV['COCOAPODS_VERSION'] = Pod::VERSION ENV.delete('CDPATH')
prepare_command = spec.prepare_command.strip_heredoc.chomp ENV['COCOAPODS_VERSION'] = Pod::VERSION
full_command = "\nset -e\n" + prepare_command prepare_command = spec.prepare_command.strip_heredoc.chomp
bash!('-c', full_command) full_command = "\nset -e\n" + prepare_command
ENV.delete('COCOAPODS_VERSION') bash!('-c', full_command)
ensure
ENV.delete('COCOAPODS_VERSION')
end
end end
end end
end end
......
...@@ -63,6 +63,13 @@ module Pod ...@@ -63,6 +63,13 @@ module Pod
@spec.prepare_command = "[ \"$COCOAPODS_VERSION\" == \"#{Pod::VERSION}\" ] || exit 1" @spec.prepare_command = "[ \"$COCOAPODS_VERSION\" == \"#{Pod::VERSION}\" ] || exit 1"
lambda { @installer.install! }.should.not.raise lambda { @installer.install! }.should.not.raise
end end
it 'doesn\'t leak the $COCOAPODS_VERSION environment variable' do
ENV['COCOAPODS_VERSION'] = nil
@spec.prepare_command = 'exit 1'
lambda { @installer.install! }.should.raise(Pod::Informative)
ENV['COCOAPODS_VERSION'].should.be.nil
end
end end
#--------------------------------------# #--------------------------------------#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment