Improved upon the implementation of the "callAsFunction(at: )" function for the CreateFoldersTask task in the library target.

This commit is contained in:
2025-01-16 01:45:41 +01:00
parent 72230c5337
commit fbb5d2d2a4
2 changed files with 27 additions and 24 deletions
+20 -9
View File
@@ -15,19 +15,30 @@ public struct CreateFoldersTask {
// MARK: Functions
public func callAsFunction(at rootFolder: URL) async throws {
let folderApp = rootFolder.appendingPath(.folderApp)
let folderAppInfrastructure = rootFolder.appendingPath(.folderAppInfrastructure)
let folderAppTestCases = rootFolder.appendingPath(.folderAppTestCases)
let folderAppTestSources = rootFolder.appendingPath(.folderAppTestSources)
try await fileService.createFolder(at: folderApp)
try await fileService.createFolder(at: folderAppInfrastructure)
try await fileService.createFolder(at: folderAppTestCases)
try await fileService.createFolder(at: folderAppTestSources)
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 {