Commit eed0a91f authored by Eloy Duran's avatar Eloy Duran

Add simple command executer.

parent 71fc2bbf
* Check exit statuses of commands performed and raise when necessary.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
dependency 'SSZipArchive', '>= 1' dependency 'SSZipArchive', '>= 1'
#dependency 'ASIHTTPRequest', '1.8' #dependency 'ASIHTTPRequest', '1.8'
#dependency 'ASIWebPageRequest', '= 1.8' dependency 'ASIWebPageRequest', '= 1.8'
# is part of ASIHTTPRequest 1.8 and 1.8.1 # is part of ASIHTTPRequest 1.8 and 1.8.1
dependency 'Reachability' #, '>= 2.0' dependency 'Reachability' #, '>= 2.0'
......
...@@ -6,6 +6,7 @@ module Pod ...@@ -6,6 +6,7 @@ module Pod
autoload :Config, 'cocoa_pods/config' autoload :Config, 'cocoa_pods/config'
autoload :Dependency, 'cocoa_pods/dependency' autoload :Dependency, 'cocoa_pods/dependency'
autoload :Downloader, 'cocoa_pods/downloader' autoload :Downloader, 'cocoa_pods/downloader'
autoload :Executable, 'cocoa_pods/executable'
autoload :Installer, 'cocoa_pods/installer' autoload :Installer, 'cocoa_pods/installer'
autoload :Resolver, 'cocoa_pods/resolver' autoload :Resolver, 'cocoa_pods/resolver'
autoload :Source, 'cocoa_pods/source' autoload :Source, 'cocoa_pods/source'
...@@ -19,7 +20,6 @@ module Pod ...@@ -19,7 +20,6 @@ module Pod
end end
autoload :Pathname, 'pathname' autoload :Pathname, 'pathname'
autoload :Executioner, 'executioner'
end end
class Pathname class Pathname
......
...@@ -40,6 +40,7 @@ module Pod ...@@ -40,6 +40,7 @@ module Pod
def self.options def self.options
" --help Show help information\n" + " --help Show help information\n" +
" --silent Print nothing\n" +
" --verbose Print more information while working" " --verbose Print more information while working"
end end
...@@ -59,6 +60,7 @@ module Pod ...@@ -59,6 +60,7 @@ module Pod
def self.parse(*argv) def self.parse(*argv)
argv = ARGV.new(argv) argv = ARGV.new(argv)
show_help = argv.option('--help') show_help = argv.option('--help')
Config.instance.silent = argv.option('--silent')
Config.instance.verbose = argv.option('--verbose') Config.instance.verbose = argv.option('--verbose')
command_class = case argv.shift_argument command_class = case argv.shift_argument
......
require 'executioner'
require 'fileutils' require 'fileutils'
module Pod module Pod
...@@ -23,7 +22,7 @@ module Pod ...@@ -23,7 +22,7 @@ module Pod
Changes the current working dir to the local spec-repo `NAME'.} Changes the current working dir to the local spec-repo `NAME'.}
end end
include Executioner extend Executable
executable :git executable :git
def initialize(argv) def initialize(argv)
......
...@@ -16,11 +16,7 @@ module Pod ...@@ -16,11 +16,7 @@ module Pod
end end
class Git < Downloader class Git < Downloader
require 'executioner' extend Executable
include Executioner
# TODO make Executioner:
# * not raise when there's output to either stdout/stderr, but check exit status
# * sync output
executable :git executable :git
def download def download
...@@ -38,16 +34,16 @@ module Pod ...@@ -38,16 +34,16 @@ module Pod
Dir.chdir(@pod_root) do Dir.chdir(@pod_root) do
git "init" git "init"
git "remote add origin '#{@url}'" git "remote add origin '#{@url}'"
git "fetch origin tags/#{@options[:tag]} 2>&1" git "fetch origin tags/#{@options[:tag]}"
git "reset --hard FETCH_HEAD" git "reset --hard FETCH_HEAD"
git "checkout -b activated-pod-commit 2>&1" git "checkout -b activated-pod-commit"
end end
end end
def download_commit def download_commit
git "clone '#{@url}' '#{@pod_root}'" git "clone '#{@url}' '#{@pod_root}'"
Dir.chdir(@pod_root) do Dir.chdir(@pod_root) do
git "checkout -b activated-pod-commit #{@options[:commit]} 2>&1" git "checkout -b activated-pod-commit #{@options[:commit]}"
end end
end end
......
module Pod
module Executable
def executable(name)
define_method(name) do |command|
if Config.instance.verbose?
`#{name} #{command} 1>&2`
else
`#{name} #{command} 2> /dev/null`
end
end
end
end
end
require 'spec_helper/temporary_directory' require 'spec_helper/temporary_directory'
require 'executioner'
module SpecHelper module SpecHelper
def self.tmp_repos_path def self.tmp_repos_path
...@@ -16,7 +15,7 @@ module SpecHelper ...@@ -16,7 +15,7 @@ module SpecHelper
tmp_repos_path + 'master' tmp_repos_path + 'master'
end end
include Executioner extend Pod::Executable
executable :git executable :git
alias_method :git_super, :git alias_method :git_super, :git
......
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