feat: Adds generate commands that call to pandoc to generate pdf, latex, and html files from a project.
This commit is contained in:
@@ -143,23 +143,6 @@ func generateFindEnvironments(file: File) -> [[String: String]] {
|
||||
]
|
||||
}
|
||||
|
||||
// swiftlint:disable force_try
|
||||
func withTemporaryDirectory(
|
||||
_ operation: @Sendable (URL) async throws -> Void
|
||||
) async rethrows {
|
||||
let dir = FileManager.default.temporaryDirectory
|
||||
let tempDir = dir.appending(path: UUID().uuidString)
|
||||
|
||||
try! FileManager.default.createDirectory(
|
||||
atPath: tempDir.cleanFilePath,
|
||||
withIntermediateDirectories: false
|
||||
)
|
||||
try await operation(tempDir)
|
||||
try! FileManager.default.removeItem(at: tempDir)
|
||||
}
|
||||
|
||||
// swiftlint:enable force_try
|
||||
|
||||
func withGeneratedConfigFile(
|
||||
named fileName: String,
|
||||
client: ConfigurationClient,
|
||||
|
||||
@@ -5,6 +5,7 @@ import Foundation
|
||||
@_spi(Internal) import PlaybookClient
|
||||
import ShellClient
|
||||
import Testing
|
||||
import TestSupport
|
||||
|
||||
@Suite("PlaybookClientTests")
|
||||
struct PlaybookClientTests {
|
||||
@@ -15,18 +16,17 @@ struct PlaybookClientTests {
|
||||
$0.fileClient = .liveValue
|
||||
$0.asyncShellClient = .liveValue
|
||||
} operation: {
|
||||
let tempDirectory = FileManager.default.temporaryDirectory
|
||||
let pathUrl = tempDirectory.appending(path: "playbook")
|
||||
let playbookClient = PlaybookClient.liveValue
|
||||
try await withTemporaryDirectory { tempDirectory in
|
||||
let pathUrl = tempDirectory.appending(path: "playbook")
|
||||
let playbookClient = PlaybookClient.liveValue
|
||||
|
||||
let configuration = Configuration(playbook: .init(directory: pathUrl.cleanFilePath))
|
||||
let configuration = Configuration(playbook: .init(directory: pathUrl.cleanFilePath))
|
||||
|
||||
try? FileManager.default.removeItem(at: pathUrl)
|
||||
try await playbookClient.installPlaybook(configuration)
|
||||
let exists = FileManager.default.fileExists(atPath: pathUrl.cleanFilePath)
|
||||
#expect(exists)
|
||||
|
||||
try FileManager.default.removeItem(at: pathUrl)
|
||||
try? FileManager.default.removeItem(at: pathUrl)
|
||||
try await playbookClient.installPlaybook(configuration)
|
||||
let exists = FileManager.default.fileExists(atPath: pathUrl.cleanFilePath)
|
||||
#expect(exists)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user