This commit is contained in:
2026-02-15 14:06:35 +01:00
parent c961342462
commit 2679f688d5
8 changed files with 53 additions and 67 deletions

View File

@@ -5,15 +5,13 @@ import node.childProcess.exec
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
internal actual suspend fun execute(
command: Array<String>,
directory: String?,
): Shell.Result = suspendCoroutine { continuation ->
val command = command.joinToString(" ") { "\"$it\"" }
val options = ExecOptions.invoke(cwd = directory)
actual suspend fun execute(vararg command: String, directory: String?): Result = suspendCoroutine { continuation ->
val command = command.joinToString(" ") { """"$it"""" }
val options = ExecOptions(cwd = directory)
exec(command, options) { error, stdout, stderr ->
val code = if (error == null) 0 else error.code!!.toInt()
val value = (if (error == null) stdout else stderr) as String
continuation.resume(Shell.Result(code, value))
val code = error?.code?.toInt() ?: 0
val result = Result.from(code, { stdout as String }, { stderr as String })
continuation.resume(result)
}
}