Skip to content

Commit

Permalink
Merge pull request #39 from mono0926/fix-rename-log
Browse files Browse the repository at this point in the history
Fix renamed libraries log bug
  • Loading branch information
mono0926 authored May 9, 2017
2 parents d515f41 + 15163c8 commit fac87c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Sources/LicensePlistCore/Entity/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ struct Config {
self.githubs.forEach { Log.warning("\($0.name) was loaded from config YAML.") }
return filterExcluded((self.githubs + githubs))
}
func rename(licenses: [LicenseInfo]) -> [LicenseInfo] {
return licenses.map { name in
func rename<T>(_ names: [T]) -> [T] where T: HasChangeableName {
return names.map { name in
if let to = renames[name.name] {
var name = name
name.name = to
Expand Down
9 changes: 4 additions & 5 deletions Sources/LicensePlistCore/LicensePlist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final class LicensePlist {
var cocoaPodsLicenses = podsAcknowledgements
.map { CocoaPodsLicense.parse($0) }
.flatMap { $0 }
cocoaPodsLicenses = config.filterExcluded(cocoaPodsLicenses)
cocoaPodsLicenses = config.rename(config.filterExcluded(cocoaPodsLicenses))

Log.info("Carthage License collect start")

Expand All @@ -61,17 +61,16 @@ public final class LicensePlist {
let queue = OperationQueue()
let carthageOperations = gitHubLibraries.map { GitHubLicense.collect($0) }
queue.addOperations(carthageOperations, waitUntilFinished: true)
let carthageLicenses = carthageOperations.map { $0.result?.value }.flatMap { $0 }
self.githubLibraries = gitHubLibraries
let carthageLicenses = config.rename(carthageOperations.map { $0.result?.value }.flatMap { $0 })
self.githubLibraries = config.rename(gitHubLibraries)

let licenses = ((cocoaPodsLicenses as [LicenseInfo]) + (carthageLicenses as [LicenseInfo]))
return ((cocoaPodsLicenses as [LicenseInfo]) + (carthageLicenses as [LicenseInfo]))
.reduce([String: LicenseInfo]()) { sum, e in
var sum = sum
sum[e.name] = e
return sum
}.values
.sorted { $0.name.lowercased() < $1.name.lowercased() }
return config.rename(licenses: licenses)
}

private func reportMissings(licenses: [LicenseInfo]) {
Expand Down

0 comments on commit fac87c4

Please sign in to comment.