Commit c7b274f5 authored by Fabio Pelosin's avatar Fabio Pelosin

Merge pull request #1252 from CocoaPods/feature-prepare_command

[Specification::DSL] Add prepare_command
parents a0160e7c 4048558d
......@@ -6,18 +6,22 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
###### Enhancements
* Added support for resource bundles.
* Added `resource_bundles` attribute to Specification DSL.
[#743](https://github.com/CocoaPods/CocoaPods/issues/743),
[#1186](https://github.com/CocoaPods/CocoaPods/issues/1186)
* Added support for bundled frameworks.
* Added `vendored_frameworks` attribute to Specification DSL.
[#809](https://github.com/CocoaPods/CocoaPods/issues/809),
[#1075](https://github.com/CocoaPods/CocoaPods/issues/1075)
* Added support for bundled libraries.
* Added `vendored_libraries` attribute to Specification DSL.
[#809](https://github.com/CocoaPods/CocoaPods/issues/809),
[#1075](https://github.com/CocoaPods/CocoaPods/issues/1075)
* Added `prepare_command` attribute to Specification DSL. The prepare command
will replace the pre_install hook. The post_install hook has been deprecated.
[#1247](https://github.com/CocoaPods/CocoaPods/issues/1247)
* Restructured `.cocoapods` folder to contain repos in a subdirectory.
[#1150](https://github.com/CocoaPods/CocoaPods/issues/1150)
[Ian Ynda-Hummel](https://github.com/ianyh)
......
......@@ -7,7 +7,7 @@ gemspec
group :development do
# To develop the deps in tandem use the `LOCAL GIT REPOS` feature of Bundler.
gem 'cocoapods-core', :git => "https://github.com/CocoaPods/Core.git", :branch => 'master'
gem 'cocoapods-core', :git => "https://github.com/CocoaPods/Core.git", :branch => 'feature-prepare_command'
gem 'xcodeproj', :git => "https://github.com/CocoaPods/Xcodeproj.git", :branch => 'master'
gem 'cocoapods-downloader', :git => "https://github.com/CocoaPods/cocoapods-downloader.git", :branch => 'master'
gem 'claide', :git => 'https://github.com/CocoaPods/CLAide.git', :branch => 'master'
......
......@@ -7,7 +7,7 @@ GIT
GIT
remote: https://github.com/CocoaPods/Core.git
revision: 2558ca127435e10a60349c503218e8a1e4eb494c
revision: 7738d01101994723deebb907f2414b78fcb6988e
branch: feature-prepare_command
specs:
cocoapods-core (0.22.3)
......
require 'active_support/core_ext/string/strip'
module Pod
class Installer
......@@ -60,6 +62,7 @@ module Pod
#
def install!
download_source unless predownloaded? || local?
run_prepare_command
end
# Cleans the installations if appropriate.
......@@ -106,6 +109,24 @@ module Pod
end
end
extend Executable
executable :bash
# Runs the prepare command bash script of the spec.
#
# @return [void]
#
def run_prepare_command
return unless root_spec.prepare_command
UI.section(" > Running prepare command", '', 1) do
Dir.chdir(root) do
prepare_command = root_spec.prepare_command.strip_heredoc.chomp
full_command = "\nset -e\n" + prepare_command
bash!(full_command)
end
end
end
# Removes all the files not needed for the installation according to the
# specs by platform.
#
......
......@@ -65,6 +65,28 @@ module Pod
#--------------------------------------#
describe "Prepare command" do
it "runs the prepare command if one has been declared in the spec" do
@spec.prepare_command = "echo test"
@installer.expects(:bash!).once
@installer.install!
end
it "doesn't run the prepare command if it hasn't been declared in the spec" do
@installer.expects(:bash!).never
@installer.install!
end
it "raises if the prepare command fails" do
@spec.prepare_command = "missing_command"
should.raise Informative do
@installer.install!
end.message.should.match /command not found/
end
end
#--------------------------------------#
describe "Cleaning" do
it "cleans the paths non used by the installation" do
......
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