Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support multiple license files #21

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Sources/AckGenCLI/AckGen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ struct AckGenCLI {
static func main() {
print("Generating Acknowledgements file")

let licenseFiles: [String] = ["LICENSE", "LICENSE.txt"]

let arguments: [String] = Array(CommandLine.arguments.dropFirst())

guard let srcRoot = ProcessInfo.processInfo.environment["SRCROOT"] else {
Expand All @@ -36,9 +38,11 @@ struct AckGenCLI {
var acknowledgements = [Acknowledgement]()

for pkgDir in packageDirectories where pkgDir.prefix(1) != "." {
guard let data = fman.contents(atPath: "\(packageCachePath)/\(pkgDir)/LICENSE") else { continue }
let new = Acknowledgement(title: pkgDir, license: String(data: data, encoding: .utf8)!)
acknowledgements.append(new)
for file in licenseFiles {
guard let data = fman.contents(atPath: "\(packageCachePath)/\(pkgDir)/\(file)") else { continue }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit]
It doesn't matter for two elements, but usually I would prefer if let with an early break to prevent unnecessary loop iterations.

let new = Acknowledgement(title: pkgDir, license: String(data: data, encoding: .utf8)!)
acknowledgements.append(new)
}
}

let encoder = PropertyListEncoder()
Expand Down