Commit 1d093a5f authored by Marius Rackwitz's avatar Marius Rackwitz

Merge pull request #4933 from CocoaPods/mr-propagate-version-to-prepare_command

Propagate the CocoaPods version to the prepare_command
parents b5813f3b 6aa98a44
......@@ -16,6 +16,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Marius Rackwitz](https://github.com/mrackwitz)
[#4146](https://github.com/CocoaPods/CocoaPods/pull/4146)
* Pass `COCOAPODS_VERSION` as environment variable to the `prepare_command`.
[Marius Rackwitz](https://github.com/mrackwitz)
[#4933](https://github.com/CocoaPods/CocoaPods/pull/4933)
##### Bug Fixes
* Pods are built by default in another scoping level of the build products
......
......@@ -30,7 +30,7 @@ module Pod
# Executes the given command displaying it if in verbose mode.
#
# @param [String] bin
# @param [String] executable
# The binary to use.
#
# @param [Array<#to_s>] command
......
......@@ -58,10 +58,15 @@ module Pod
return unless spec.prepare_command
UI.section(' > Running prepare command', '', 1) do
Dir.chdir(path) do
ENV.delete('CDPATH')
prepare_command = spec.prepare_command.strip_heredoc.chomp
full_command = "\nset -e\n" + prepare_command
bash!('-c', full_command)
begin
ENV.delete('CDPATH')
ENV['COCOAPODS_VERSION'] = Pod::VERSION
prepare_command = spec.prepare_command.strip_heredoc.chomp
full_command = "\nset -e\n" + prepare_command
bash!('-c', full_command)
ensure
ENV.delete('COCOAPODS_VERSION')
end
end
end
end
......
......@@ -58,6 +58,18 @@ module Pod
@spec.prepare_command = 'cd Classes;ls Banana.h'
lambda { @installer.install! }.should.not.raise
end
it 'sets the $COCOAPODS_VERSION environment variable' do
@spec.prepare_command = "[ \"$COCOAPODS_VERSION\" == \"#{Pod::VERSION}\" ] || exit 1"
lambda { @installer.install! }.should.not.raise
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
#--------------------------------------#
......
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