feat: Updates to check if playbook is installed prior to running any of the commands, updates tests.
This commit is contained in:
@@ -120,7 +120,11 @@ struct LiveFileClient: Sendable {
|
||||
|
||||
func isDirectory(_ url: URL) -> Bool {
|
||||
var isDirectory: ObjCBool = false
|
||||
manager.fileExists(atPath: url.cleanFilePath, isDirectory: &isDirectory)
|
||||
#if os(Linux)
|
||||
_ = manager.fileExists(atPath: url.cleanFilePath, isDirectory: &isDirectory)
|
||||
#else
|
||||
manager.fileExists(atPath: url.cleanFilePath, isDirectory: &isDirectory)
|
||||
#endif
|
||||
return isDirectory.boolValue
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,8 @@ extension PlaybookClient.RunPlaybook.SharedRunOptions {
|
||||
) async throws -> T {
|
||||
@Dependency(\.commandClient) var commandClient
|
||||
|
||||
try await ensurePlaybookExists()
|
||||
|
||||
return try await commandClient.run(
|
||||
logging: loggingOptions,
|
||||
quiet: quiet,
|
||||
@@ -101,6 +103,17 @@ extension PlaybookClient.RunPlaybook.SharedRunOptions {
|
||||
return (arguments, output)
|
||||
}
|
||||
}
|
||||
|
||||
private func ensurePlaybookExists() async throws {
|
||||
@Dependency(\.fileClient) var fileClient
|
||||
@Dependency(\.playbookClient.repository) var repository
|
||||
|
||||
let directory = try await repository.directory()
|
||||
let exists = try await fileClient.isDirectory(URL(filePath: directory))
|
||||
if !exists {
|
||||
try await repository.install()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@_spi(Internal)
|
||||
|
||||
Reference in New Issue
Block a user