Commit d6b531c6 authored by Kra Larivain's avatar Kra Larivain

- added support for lint-ing a folder with multiple specs

parent 0e1d101d
...@@ -97,6 +97,7 @@ module Pod ...@@ -97,6 +97,7 @@ module Pod
@quick = argv.flag?('quick') @quick = argv.flag?('quick')
@only_errors = argv.flag?('only-errors') @only_errors = argv.flag?('only-errors')
@clean = argv.flag?('clean', true) @clean = argv.flag?('clean', true)
@podspecs_paths = argv.arguments!
super super
end end
...@@ -106,27 +107,29 @@ module Pod ...@@ -106,27 +107,29 @@ module Pod
def run def run
UI.puts UI.puts
validator = Validator.new(podspec_to_lint) podspecs_to_lint.each do |podspec|
validator.local = true
validator.quick = @quick validator = Validator.new(podspec)
validator.no_clean = !@clean validator.local = true
validator.only_errors = @only_errors validator.quick = @quick
validator.validate validator.no_clean = !@clean
validator.only_errors = @only_errors
unless @clean validator.validate
UI.puts "Pods project available at `#{validator.validation_dir}/Pods/Pods.xcodeproj` for inspection."
UI.puts unless @clean
end UI.puts "Pods project available at `#{validator.validation_dir}/Pods/Pods.xcodeproj` for inspection."
UI.puts
if validator.validated? end
UI.puts "#{validator.spec.name} passed validation.".green if validator.validated?
else UI.puts "#{validator.spec.name} passed validation.".green
message = "#{validator.spec.name} did not pass validation." else
if @clean message = "#{validator.spec.name} did not pass validation."
message << "\nYou can use the `--no-clean` option to inspect " \ if @clean
"any issue." message << "\nYou can use the `--no-clean` option to inspect " \
"any issue."
end
raise Informative, message
end end
raise Informative, message
end end
end end
...@@ -142,11 +145,14 @@ module Pod ...@@ -142,11 +145,14 @@ module Pod
# @raise If no podspec is found. # @raise If no podspec is found.
# @raise If multiple podspecs are found. # @raise If multiple podspecs are found.
# #
def podspec_to_lint def podspecs_to_lint
podspecs = Pathname.glob(Pathname.pwd + '*.podspec{.yaml,}') if !@podspecs_paths.empty? then
raise Informative, "Unable to find a podspec in the working directory" if podspecs.count.zero? Array(@podspecs_paths)
raise Informative, "Multiple podspecs detected in the working directory" if podspecs.count > 1 else
podspecs.first podspecs = Pathname.glob(Pathname.pwd + '*.podspec{.yaml,}')
raise Informative, "Unable to find a podspec in the working directory" if podspecs.count.zero?
podspecs
end
end end
end end
......
...@@ -12,5 +12,23 @@ module Pod ...@@ -12,5 +12,23 @@ module Pod
lambda { run_command('lib', 'create', 'Pod Name With Spaces') }.should.raise CLAide::Help lambda { run_command('lib', 'create', 'Pod Name With Spaces') }.should.raise CLAide::Help
end end
end end
describe Command::Lib::Lint do
it "lints the current working directory" do
Dir.chdir(fixture('integration/Reachability')) do
cmd = command('lib', 'lint', '--only-errors')
cmd.run
UI.output.should.include "passed validation"
end
end
it "lints a single spec in the current working directory" do
Dir.chdir(fixture('integration/Reachability')) do
cmd = command('lib', 'lint', 'Reachability.podspec', '--quick', '--only-errors')
cmd.run
UI.output.should.include "passed validation"
end
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