Commit 8126b727 authored by Eric Amorde's avatar Eric Amorde

Warn instead of throwing an exception when a development pod's podspec specifies…

Warn instead of throwing an exception when a development pod's podspec specifies a license file that does not exist
parent 1828d95c
......@@ -25,6 +25,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Bug Fixes
* Warn instead of throwing an exception when a development pod specifies an invalid license file path
[Eric Amorde](https://github.com/amorde)
[#7377](https://github.com/CocoaPods/CocoaPods/issues/7377)
* Better static frameworks transitive dependency error checking
[Paul Beusterien](https://github.com/paulb777)
[#7352](https://github.com/CocoaPods/CocoaPods/issues/7352)
......
......@@ -73,13 +73,16 @@ module Pod
return nil unless spec.license
text = spec.license[:text]
unless text
if license_file = file_accessor(spec).license
if license_file.exist?
text = IO.read(license_file)
if license_file = spec.license[:file]
license_path = file_accessor(spec).root + license_file
if File.exist?(license_path)
text = IO.read(license_path)
else
UI.warn "Unable to read the license file `#{license_file}` " \
"for the spec `#{spec}`"
end
elsif license_file = file_accessor(spec).license
text = IO.read(license_file)
end
end
text
......
......@@ -278,11 +278,7 @@ module Pod
# specification or auto-detected.
#
def license
if file = spec_consumer.license[:file]
path_list.root + file
else
path_list.glob([GLOB_PATTERNS[:license]]).first
end
spec_license || path_list.glob([GLOB_PATTERNS[:license]]).first
end
# @return [Pathname, Nil] The path of the custom module map file of the
......@@ -305,17 +301,37 @@ module Pod
path_list.glob([GLOB_PATTERNS[:docs]])
end
# @return [Pathname] The path of the license file specified in the
# specification, if it exists
#
def spec_license
if file = spec_consumer.license[:file]
absolute_path = root + file
absolute_path if File.exist?(absolute_path)
end
end
# @return [Array<Pathname>] Paths to include for local pods to assist in development
#
def developer_files
podspecs = specs
result = [module_map, prefix_header]
if license_path = spec_consumer.license[:file]
license_path = root + license_path
unless File.exist?(license_path)
UI.warn "A license was specified in podspec `#{spec.name}` but the file does not exist - #{license_path}"
end
end
if podspecs.size <= 1
result += [license, readme, podspecs, docs]
else
# Manually add non-globbing files since there are multiple podspecs in the same folder
result << podspec_file
if file = spec_consumer.license[:file]
result << root + file
if license_file = spec_license
absolute_path = root + license_file
result << absolute_path if File.exist?(absolute_path)
end
end
result.compact.flatten.sort
......
......@@ -211,6 +211,24 @@ module Pod
@accessor.license.should == @root + 'LICENSE'
end
describe '#spec_license' do
it 'returns the license file of the specification' do
@accessor.spec_license.should == @root + 'LICENSE'
end
it 'does not auto-detect the license' do
FileUtils.cp(@root + 'LICENSE', @root + 'LICENSE_TEMP')
@spec_consumer.stubs(:license).returns({})
@accessor.spec_license.should.be.nil
FileUtils.rm_f(@root + 'LICENSE_TEMP')
end
it 'returns nil if the license file path does not exist' do
@spec_consumer.stubs(:license).returns(:file => 'MISSING_PATH')
@accessor.spec_license.should.be.nil
end
end
it 'returns the docs of the specification' do
@accessor.docs.should == [
@root + 'docs/guide1.md',
......@@ -241,6 +259,20 @@ module Pod
]
end
it 'warns when a LICENSE file is specified but the path does not exist' do
@spec_consumer.stubs(:license).returns(:file => 'PathThatDoesNotExist/LICENSE')
@accessor.developer_files.should == [
@root + 'Banana.modulemap',
@root + 'BananaLib.podspec',
@root + 'Classes/BananaLib.pch',
@root + 'LICENSE', # Found by globbing
@root + 'README',
@root + 'docs/guide1.md',
@root + 'docs/subdir/guide2.md',
]
UI.warnings.should.include "A license was specified in podspec `#{@spec_consumer.name}` but the file does not exist - #{@accessor.root + 'PathThatDoesNotExist/LICENSE'}\n"
end
it 'does not return auto-detected developer files when there are multiple podspecs' do
@accessor.stubs(:specs).returns([@root + 'BananaLib.podspec', @root + 'OtherLib.podspec'])
@accessor.developer_files.should == [
......
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