50 lines
1.1 KiB
Swift
50 lines
1.1 KiB
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] = [
|
|
.folderApp,
|
|
.folderAppInfrastructure,
|
|
.folderAppTestCases,
|
|
.folderAppTestSources
|
|
]
|
|
|
|
}
|
|
|
|
// MARK: - String+Constants
|
|
|
|
private extension String {
|
|
static let folderApp = "Sources/App"
|
|
static let folderAppInfrastructure = "Sources/AppInfrastructure"
|
|
static let folderAppTestCases = "Tests/App/Cases"
|
|
static let folderAppTestSources = "Tests/App/Sources"
|
|
}
|