diff --git a/lib/bibliothecary/parsers/nuget.rb b/lib/bibliothecary/parsers/nuget.rb index 3a8664db..77cb4adb 100644 --- a/lib/bibliothecary/parsers/nuget.rb +++ b/lib/bibliothecary/parsers/nuget.rb @@ -70,10 +70,12 @@ def self.parse_packages_lock_json(file_contents) if frameworks.size > 0 # we should really return multiple manifests, but bibliothecary doesn't # do that yet so at least pick deterministically. - frameworks[frameworks.keys.sort.last] - else - [] + + # Note, frameworks can be empty, so remove empty ones and then return the last sorted item if any + frameworks = frameworks.delete_if { |k, v| v.empty? } + return frameworks[frameworks.keys.sort.last] unless frameworks.empty? end + [] end def self.parse_packages_config(file_contents) diff --git a/spec/fixtures/packages.lock.json b/spec/fixtures/packages.lock.json index fb765a6e..cf596059 100644 --- a/spec/fixtures/packages.lock.json +++ b/spec/fixtures/packages.lock.json @@ -1,6 +1,7 @@ { "version": 1, "dependencies": { + ".Empty-group-earlier-alphabetically": {}, ".NETCoreApp,Version=v2.2": { "Microsoft.AspNetCore.App": { "type": "Direct", @@ -3099,6 +3100,7 @@ "System.Xml.XPath": "4.3.0" } } - } + }, + "Empty-group-later-alphabetically": {} } -} \ No newline at end of file +}