initial commit
Some checks failed
/ publish (push) Failing after 53s

This commit is contained in:
2025-07-12 20:23:00 +02:00
commit 3565632465
14 changed files with 717 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
package com.infendro.shell
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
import node.childProcess.ExecOptions
import node.childProcess.exec
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)
exec(command, options) { error, stdout, stderr ->
val code = if (error == null) 0 else error.code!!.toInt()
val value = if (error == null) stdout else stderr
continuation.resume(Shell.Result(code, value))
}
}