Implemented the CopyFilesTask task in the library target.

This commit is contained in:
2025-01-16 01:35:52 +01:00
parent 95698a2824
commit 72230c5337
2 changed files with 96 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
import Foundation
public struct CopyFilesTask {
// MARK: Properties
private let fileService: FileServicing
// MARK: Initialisers
public init(fileService: FileServicing) {
self.fileService = fileService
}
// MARK: Functions
public func callAsFunction(to rootFolder: URL) async throws {
let filesFolder = URL(at: .folderFiles)
for fileToCopy in Self.filesToCopy {
try await fileService.copyItem(
from: filesFolder.appendingPath(fileToCopy),
to: rootFolder.appendingPath(fileToCopy)
)
}
}
}
// MARK: - Helpers
extension CopyFilesTask {
// MARK: Constants
static let filesToCopy: [String] = [
.fileDockerIgnore,
.fileGitIgnore,
.fileLicense,
.fileReadme
]
}
// MARK: - URL+Constants
private extension String {
static let folderFiles = "./Resources/Files"
static let fileDockerIgnore = ".dockerignore"
static let fileGitIgnore = ".gitignore"
static let fileLicense = "LICENSE"
static let fileReadme = "README.md"
}