Skip to content

Commit

Permalink
[FIXED] Nuget and dotnet not returning proper licenses
Browse files Browse the repository at this point in the history
  • Loading branch information
xtreme-shane-lattanzio committed May 11, 2022
1 parent 5b54cf9 commit e345233
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/license_finder/package_managers/dotnet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ def initialize(name, version, possible_spec_paths)
end

def read_license_urls
possible_spec_paths.flat_map do |path|
raw_licenses = possible_spec_paths.flat_map do |path|
Nuget.nuspec_license_urls(File.read(path)) if File.exist? path
end.compact

raw_licenses&.map! do |license|
license.gsub('https://licenses.nuget.org/', '')
end
end

def ==(other)
Expand All @@ -61,7 +65,6 @@ def current_packages
package_metadatas = asset_files
.flat_map { |path| AssetFile.new(path).dependencies }
.uniq { |d| [d.name, d.version] }

package_metadatas.map do |d|
path = Dir.glob("#{Dir.home}/.nuget/packages/#{d.name.downcase}/#{d.version}").first
NugetPackage.new(d.name, d.version, spec_licenses: d.read_license_urls, install_path: path)
Expand Down
5 changes: 5 additions & 0 deletions lib/license_finder/package_managers/nuget.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def assemblies
def current_packages
dependencies.each_with_object({}) do |dep, memo|
licenses = license_urls(dep)
licenses&.map! do |license|
license.gsub('https://licenses.nuget.org/', '')
end

path = Dir.glob("#{Dir.home}/.nuget/packages/#{dep.name.downcase}/#{dep.version}").first

memo[dep.name] ||= NugetPackage.new(dep.name, dep.version, spec_licenses: licenses, install_path: path)
Expand All @@ -60,6 +64,7 @@ def current_packages

def license_urls(dep)
files = Dir["**/#{dep.name}.#{dep.version}.nupkg"]

return nil if files.empty?

file = files.first
Expand Down

0 comments on commit e345233

Please sign in to comment.