Skip to content

Commit

Permalink
Support of latest Conan v1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
melter2m committed Jun 21, 2023
1 parent 5252cfc commit ef81af3
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions lib/license_finder/package_managers/conan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ def possible_package_paths
[project_path.join('conanfile.txt')]
end

def license_file_is_good?(license_file_path)
license_file_path != nil && File.file?(license_file_path)
end

def license_file(project_path, name)
candidates = Dir.glob("#{project_path}/licenses/#{name}/**/LICENSE*")
candidates.each do |candidate|
if license_file_is_good?(candidate)
return candidate
end
end
nil
end

def current_packages
install_command = 'conan install .'
info_command = 'conan info .'
Expand All @@ -19,9 +33,14 @@ def current_packages
deps = info_parser.parse(info_output)
deps.map do |dep|
name, version = dep['name'].split('/')
license_file_path = license_file(project_path, name)

unless license_file_is_good?(license_file_path)
next
end

url = dep['URL']
license_file_path = Dir.glob("#{project_path}/licenses/#{name}/**/LICENSE*").first
ConanPackage.new(name, version, File.open(license_file_path).read, url) unless name == 'conanfile.txt'
ConanPackage.new(name, version, File.open(license_file_path).read, url)
end.compact
end
end
Expand Down

0 comments on commit ef81af3

Please sign in to comment.