Implemented the CopyFilesTask task in the library target.
This commit is contained in:
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user