From 3a12bb06c2fea735bb5627c5d95ff860d6b7ed44 Mon Sep 17 00:00:00 2001 From: Nils Botha Date: Wed, 15 Dec 2021 13:05:02 +0100 Subject: [PATCH] Adds --add-version-numbers option to --single-page option --- Sources/LicensePlistCore/Entity/LicensePlistHolder.swift | 4 ++-- Sources/LicensePlistCore/Entity/PlistInfo.swift | 2 +- Tests/LicensePlistTests/Entity/LicensePlistHolderTests.swift | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/LicensePlistCore/Entity/LicensePlistHolder.swift b/Sources/LicensePlistCore/Entity/LicensePlistHolder.swift index 91b1c168..684e01ee 100644 --- a/Sources/LicensePlistCore/Entity/LicensePlistHolder.swift +++ b/Sources/LicensePlistCore/Entity/LicensePlistHolder.swift @@ -38,13 +38,13 @@ struct LicensePlistHolder { return LicensePlistHolder(root: root, items: items) } - static func loadAllToRoot(licenses: [LicenseInfo]) -> LicensePlistHolder { + static func loadAllToRoot(licenses: [LicenseInfo], options: Options) -> LicensePlistHolder { let rootItem: [[String: String]] = { guard !licenses.isEmpty else { return [] } let body = licenses .compactMap { lincense in return ["Type": "PSGroupSpecifier", - "Title": lincense.name, + "Title": lincense.name(withVersion: options.config.addVersionNumbers), "FooterText": lincense.body ] } diff --git a/Sources/LicensePlistCore/Entity/PlistInfo.swift b/Sources/LicensePlistCore/Entity/PlistInfo.swift index f6181317..c474a8d7 100644 --- a/Sources/LicensePlistCore/Entity/PlistInfo.swift +++ b/Sources/LicensePlistCore/Entity/PlistInfo.swift @@ -119,7 +119,7 @@ struct PlistInfo { Log.info("Directory created: \(outputPath)") let holder = options.config.singlePage ? - LicensePlistHolder.loadAllToRoot(licenses: licenses) : + LicensePlistHolder.loadAllToRoot(licenses: licenses, options: options) : LicensePlistHolder.load(licenses: licenses, options: options) holder.write(to: outputPath.appendingPathComponent("\(options.prefix).plist"), itemsPath: itemsPath) diff --git a/Tests/LicensePlistTests/Entity/LicensePlistHolderTests.swift b/Tests/LicensePlistTests/Entity/LicensePlistHolderTests.swift index d193f364..38973c8e 100644 --- a/Tests/LicensePlistTests/Entity/LicensePlistHolderTests.swift +++ b/Tests/LicensePlistTests/Entity/LicensePlistHolderTests.swift @@ -36,7 +36,7 @@ class LicensePlistHolderTests: XCTestCase { func testLoad_allToRoot() throws { let pods = CocoaPods(name: "name", nameSpecified: nil, version: nil) let podsLicense = CocoaPodsLicense(library: pods, body: "'") - let result = LicensePlistHolder.loadAllToRoot(licenses: [podsLicense]) + let result = LicensePlistHolder.loadAllToRoot(licenses: [podsLicense], options: Options.empty) let (root, items) = result.deserialized() let rootItems = try XCTUnwrap(root["PreferenceSpecifiers"]) XCTAssertEqual(rootItems.count, 1)