Renamed the ResourceFile enumeration in the library target as File and also, implemented its "filePath" and "resourcePath" properties.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
enum File: String {
|
||||
case dockerIgnore = "docker_ignore"
|
||||
case gitIgnore = "git_ignore"
|
||||
case license
|
||||
case package
|
||||
case readme
|
||||
}
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
extension File {
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
var fileName: String {
|
||||
switch self {
|
||||
case .dockerIgnore: ".dockerignore"
|
||||
case .gitIgnore: ".gitignore"
|
||||
case .license: "LICENSE"
|
||||
case .readme: "README.md"
|
||||
case .package: "Package.swift"
|
||||
}
|
||||
}
|
||||
|
||||
var filePath: String {
|
||||
switch self {
|
||||
default: fileName
|
||||
}
|
||||
}
|
||||
|
||||
var resourcePath: String {
|
||||
switch self {
|
||||
default: "Resources/Files"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - CaseIterable
|
||||
|
||||
extension File: CaseIterable {}
|
||||
@@ -1,29 +0,0 @@
|
||||
enum ResourceFile: String {
|
||||
case dockerIgnore = "docker_ignore"
|
||||
case gitIgnore = "git_ignore"
|
||||
case license
|
||||
case package
|
||||
case readme
|
||||
}
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
extension ResourceFile {
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
var fileName: String {
|
||||
switch self {
|
||||
case .dockerIgnore: return ".dockerignore"
|
||||
case .gitIgnore: return ".gitignore"
|
||||
case .license: return "LICENSE"
|
||||
case .readme: return "README.md"
|
||||
case .package: return "Package.swift"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - CaseIterable
|
||||
|
||||
extension ResourceFile: CaseIterable {}
|
||||
@@ -20,17 +20,17 @@ public struct CopyFilesTask {
|
||||
// MARK: Functions
|
||||
|
||||
public func callAsFunction(to rootFolder: URL) async throws (FileServiceError) {
|
||||
for resource in ResourceFile.allCases {
|
||||
for resource in File.allCases {
|
||||
guard let source = bundleService.url(
|
||||
forResource: resource.rawValue,
|
||||
withExtension: nil,
|
||||
subdirectory: "Resources/Files"
|
||||
subdirectory: resource.resourcePath
|
||||
) else {
|
||||
assertionFailure("URL should have been initialized.")
|
||||
return
|
||||
}
|
||||
|
||||
let destination = rootFolder.appendingPath(resource.fileName)
|
||||
let destination = rootFolder.appendingPath(resource.filePath)
|
||||
|
||||
try await fileService.copyFile(from: source, to: destination)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user