Commit 5d9d15ea authored by Samuel E. Giddins's avatar Samuel E. Giddins

Merge pull request #2184 from CocoaPods/config-project-directory

[Command] Add option to configure project directory
parents 88742dd0 3164786c
...@@ -59,6 +59,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides ...@@ -59,6 +59,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[Fabio Pelosin][FabioPelosin] [Fabio Pelosin][FabioPelosin]
[Eloy Durán](https://github.com/alloy) [Eloy Durán](https://github.com/alloy)
* Add support for user-specified project directories with the
`--project-directory` option
[Samuel Giddins](segiddins)
[#2183](https://github.com/CocoaPods/CocoaPods/issues/2183)
##### Bug Fixes ##### Bug Fixes
* Fixed pod repo push to first check if Specs directory exists and if so push * Fixed pod repo push to first check if Specs directory exists and if so push
......
...@@ -27,6 +27,8 @@ module Pod ...@@ -27,6 +27,8 @@ module Pod
self.description = 'CocoaPods, the Objective-C library package manager.' self.description = 'CocoaPods, the Objective-C library package manager.'
self.plugin_prefix = 'cocoapods' self.plugin_prefix = 'cocoapods'
[Install, Update, Outdated, IPC::Podfile, IPC::Repl].each { |c| c.send(:include, ProjectDirectory) }
def self.options def self.options
[ [
['--silent', 'Show nothing'], ['--silent', 'Show nothing'],
...@@ -97,7 +99,7 @@ module Pod ...@@ -97,7 +99,7 @@ module Pod
# #
def verify_podfile_exists! def verify_podfile_exists!
unless config.podfile unless config.podfile
raise Informative, "No `Podfile' found in the current working directory." raise Informative, "No `Podfile' found in the project directory."
end end
end end
...@@ -109,7 +111,7 @@ module Pod ...@@ -109,7 +111,7 @@ module Pod
# #
def verify_lockfile_exists! def verify_lockfile_exists!
unless config.lockfile unless config.lockfile
raise Informative, "No `Podfile.lock' found in the current working directory, run `pod install'." raise Informative, "No `Podfile.lock' found in the project directory, run `pod install'."
end end
end end
end end
......
module Pod module Pod
class Command class Command
# Provides support the common behaviour of the `install` and `update` # Provides support for commands to take a user-specified `project directory`
#
module ProjectDirectory
module Options
def options
[
['--project-directory=/path/to/project/directory/', 'The path to the root of the project directory'],
].concat(super)
end
end
def self.included(base)
base.extend(Options)
end
def initialize(argv)
if project_directory = argv.option('project-directory')
@project_directory = Pathname.new(project_directory).expand_path
end
config.installation_root = @project_directory
super
end
def validate!
super
if @project_directory && !@project_directory.directory?
raise Informative,
"`#{@project_directory}` is not a valid directory."
end
end
end
# Provides support for the common behaviour of the `install` and `update`
# commands. # commands.
# #
module Project module Project
......
...@@ -4,17 +4,17 @@ module Pod ...@@ -4,17 +4,17 @@ module Pod
describe Command::Outdated do describe Command::Outdated do
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
it 'tells the user that no Podfile was found in the current working dir' do it 'tells the user that no Podfile was found in the project dir' do
exception = lambda { run_command('outdated', '--no-repo-update') }.should.raise Informative exception = lambda { run_command('outdated', '--no-repo-update') }.should.raise Informative
exception.message.should.include "No `Podfile' found in the current working directory." exception.message.should.include "No `Podfile' found in the project directory."
end end
it 'tells the user that no Lockfile was found in the current working dir' do it 'tells the user that no Lockfile was found in the project dir' do
file = temporary_directory + 'Podfile' file = temporary_directory + 'Podfile'
File.open(file, 'w') { |f| f.write('platform :ios') } File.open(file, 'w') { |f| f.write('platform :ios') }
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
exception = lambda { run_command('outdated', '--no-repo-update') }.should.raise Informative exception = lambda { run_command('outdated', '--no-repo-update') }.should.raise Informative
exception.message.should.include "No `Podfile.lock' found in the current working directory" exception.message.should.include "No `Podfile.lock' found in the project directory"
end end
end end
......
...@@ -14,9 +14,9 @@ module Pod ...@@ -14,9 +14,9 @@ module Pod
describe Command::Install do describe Command::Install do
it 'tells the user that no Podfile or podspec was found in the current working dir' do it 'tells the user that no Podfile or podspec was found in the project dir' do
exception = lambda { run_command('install', '--no-repo-update') }.should.raise Informative exception = lambda { run_command('install', '--no-repo-update') }.should.raise Informative
exception.message.should.include "No `Podfile' found in the current working directory." exception.message.should.include "No `Podfile' found in the project directory."
end end
end end
...@@ -26,12 +26,12 @@ module Pod ...@@ -26,12 +26,12 @@ module Pod
describe Command::Update do describe Command::Update do
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
it 'tells the user that no Podfile was found in the current working dir' do it 'tells the user that no Podfile was found in the project dir' do
exception = lambda { run_command('update', '--no-repo-update') }.should.raise Informative exception = lambda { run_command('update', '--no-repo-update') }.should.raise Informative
exception.message.should.include "No `Podfile' found in the current working directory." exception.message.should.include "No `Podfile' found in the project directory."
end end
it 'tells the user that no Lockfile was found in the current working dir' do it 'tells the user that no Lockfile was found in the project dir' do
file = temporary_directory + 'Podfile' file = temporary_directory + 'Podfile'
File.open(file, 'w') do |f| File.open(file, 'w') do |f|
f.puts('platform :ios') f.puts('platform :ios')
...@@ -39,7 +39,7 @@ module Pod ...@@ -39,7 +39,7 @@ module Pod
end end
Dir.chdir(temporary_directory) do Dir.chdir(temporary_directory) do
exception = lambda { run_command('update', 'Reachability', '--no-repo-update') }.should.raise Informative exception = lambda { run_command('update', 'Reachability', '--no-repo-update') }.should.raise Informative
exception.message.should.include "No `Podfile.lock' found in the current working directory" exception.message.should.include "No `Podfile.lock' found in the project directory"
end 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