Commit 3164786c authored by Samuel E. Giddins's avatar Samuel E. Giddins

[Command] Add option to configure project directory

[Command] Only set project directory if specified

[Specs] s/current working dir/project dir

[Command] Restore call to super in validate!

[Command] Make project directory parameter clearer

[Rubcocop] Fix argument alignmend in command.rb

[Command] Move project directory logic to its own module
parent 3fe8b500
......@@ -59,6 +59,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[Fabio Pelosin][FabioPelosin]
[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
* Fixed pod repo push to first check if Specs directory exists and if so push
......
......@@ -27,6 +27,8 @@ module Pod
self.description = 'CocoaPods, the Objective-C library package manager.'
self.plugin_prefix = 'cocoapods'
[Install, Update, Outdated, IPC::Podfile, IPC::Repl].each { |c| c.send(:include, ProjectDirectory) }
def self.options
[
['--silent', 'Show nothing'],
......@@ -97,7 +99,7 @@ module Pod
#
def verify_podfile_exists!
unless config.podfile
raise Informative, "No `Podfile' found in the current working directory."
raise Informative, "No `Podfile' found in the project directory."
end
end
......@@ -109,7 +111,7 @@ module Pod
#
def verify_lockfile_exists!
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
......
module Pod
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.
#
module Project
......
......@@ -4,17 +4,17 @@ module Pod
describe Command::Outdated do
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.message.should.include "No `Podfile' found in the current working directory."
exception.message.should.include "No `Podfile' found in the project directory."
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.open(file, 'w') { |f| f.write('platform :ios') }
Dir.chdir(temporary_directory) do
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
......
......@@ -14,9 +14,9 @@ module Pod
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.message.should.include "No `Podfile' found in the current working directory."
exception.message.should.include "No `Podfile' found in the project directory."
end
end
......@@ -26,12 +26,12 @@ module Pod
describe Command::Update do
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.message.should.include "No `Podfile' found in the current working directory."
exception.message.should.include "No `Podfile' found in the project directory."
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.open(file, 'w') do |f|
f.puts('platform :ios')
......@@ -39,7 +39,7 @@ module Pod
end
Dir.chdir(temporary_directory) do
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
......
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