Commit 3f214a9b authored by Marius Rackwitz's avatar Marius Rackwitz

[Command] Extract Options::RepoUpdate

parent 674f6a7c
...@@ -14,6 +14,7 @@ module Pod ...@@ -14,6 +14,7 @@ module Pod
end end
class Command < CLAide::Command class Command < CLAide::Command
require 'cocoapods/command/options/repo_update'
require 'cocoapods/command/options/project_directory' require 'cocoapods/command/options/project_directory'
include Options include Options
......
module Pod module Pod
class Command class Command
class Install < Command class Install < Command
include RepoUpdate
include ProjectDirectory include ProjectDirectory
self.summary = 'Install project dependencies to Podfile.lock versions' self.summary = 'Install project dependencies to Podfile.lock versions'
...@@ -25,15 +26,12 @@ module Pod ...@@ -25,15 +26,12 @@ module Pod
def self.options def self.options
[ [
['--repo-update', 'Force running `pod repo update` before install'], ['--repo-update', 'Force running `pod repo update` before install'],
].concat(super) ].concat(super).reject { |(name, _)| name == '--no-repo-update' }
end
def initialize(argv)
config.skip_repo_update = !argv.flag?('repo-update', false)
super
end end
def run def run
config.skip_repo_update = !repo_update?(:default => false)
verify_podfile_exists! verify_podfile_exists!
installer = installer_for_config installer = installer_for_config
installer.update = false installer.update = false
......
module Pod
class Command
module Options
# Provides support for commands to skip updating the spec repositories.
#
module RepoUpdate
module Options
def options
[
['--no-repo-update', 'Skip running `pod repo update` before install'],
].concat(super)
end
end
def self.included(base)
base.extend(Options)
end
def repo_update?(default: false)
if @repo_update.nil?
default
else
@repo_update
end
end
def initialize(argv)
@repo_update = argv.flag?('repo-update')
super
end
end
end
end
end
module Pod module Pod
class Command class Command
class Outdated < Command class Outdated < Command
include RepoUpdate
include ProjectDirectory include ProjectDirectory
self.summary = 'Show outdated project dependencies' self.summary = 'Show outdated project dependencies'
...@@ -10,17 +11,6 @@ module Pod ...@@ -10,17 +11,6 @@ module Pod
spec repos, not those from local/external sources or `:head` versions. spec repos, not those from local/external sources or `:head` versions.
DESC DESC
def self.options
[
['--no-repo-update', 'Skip running `pod repo update` before install'],
].concat(super)
end
def initialize(argv)
config.skip_repo_update = !argv.flag?('repo-update', !config.skip_repo_update)
super
end
# Run the command # Run the command
# #
# @todo the command report new dependencies added to the Podfile as # @todo the command report new dependencies added to the Podfile as
...@@ -103,7 +93,7 @@ module Pod ...@@ -103,7 +93,7 @@ module Pod
def spec_sets def spec_sets
@spec_sets ||= begin @spec_sets ||= begin
analyzer.send(:update_repositories) unless config.skip_repo_update? analyzer.send(:update_repositories) if repo_update?(:default => true)
aggregate = Source::Aggregate.new(analyzer.sources) aggregate = Source::Aggregate.new(analyzer.sources)
installed_pods.map do |pod_name| installed_pods.map do |pod_name|
aggregate.search(Dependency.new(pod_name)) aggregate.search(Dependency.new(pod_name))
......
module Pod module Pod
class Command class Command
class Update < Command class Update < Command
include RepoUpdate
include ProjectDirectory include ProjectDirectory
self.summary = 'Update outdated project dependencies and create new ' \ self.summary = 'Update outdated project dependencies and create new ' \
...@@ -18,14 +19,7 @@ module Pod ...@@ -18,14 +19,7 @@ module Pod
CLAide::Argument.new('POD_NAMES', false, true), CLAide::Argument.new('POD_NAMES', false, true),
] ]
def self.options
[
['--no-repo-update', 'Skip running `pod repo update` before install'],
].concat(super)
end
def initialize(argv) def initialize(argv)
config.skip_repo_update = !argv.flag?('repo-update', !config.skip_repo_update)
@pods = argv.arguments! unless argv.arguments.empty? @pods = argv.arguments! unless argv.arguments.empty?
super super
end end
...@@ -51,6 +45,8 @@ module Pod ...@@ -51,6 +45,8 @@ module Pod
end end
def run def run
config.skip_repo_update = !repo_update?(:default => true)
verify_podfile_exists! verify_podfile_exists!
installer = installer_for_config installer = installer_for_config
......
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