colibri/Library/Sources/Tasks/CreateFoldersTask.swift

41 lines
804 B
Swift

import Foundation
public struct CreateFoldersTask {
// MARK: Properties
private let fileService: FileServicing
// MARK: Initialisers
public init(fileService: FileServicing) {
self.fileService = fileService
}
// MARK: Functions
public func callAsFunction(at rootFolder: URL) async throws {
let folders = Self.foldersToCreate.map { rootFolder.appendingPath($0) }
for folder in folders {
try await fileService.createFolder(at: folder)
}
}
}
// MARK: - Helpers
extension CreateFoldersTask {
// MARK: Constants
static let foldersToCreate: [String] = [
"Sources/App",
"Sources/AppInfrastructure",
"Tests/App/Cases",
"Tests/App/Sources"
]
}