Skip to content
This repository was archived by the owner on Jul 6, 2026. It is now read-only.

Commit 8be203e

Browse files
committed
Make Executor command platform aware.
1 parent d8e6f1c commit 8be203e

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

lib/jetbrains/src/main/kotlin/dev/buijs/klutter/jetbrains/shared/JetbrainsExecutor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class JetbrainsExecutor: Executor() {
3535
timeout: Long?,
3636
command: String,
3737
environment: Map<String, String>,
38-
): String = GeneralCommandLine(command.split(" "))
38+
): String = GeneralCommandLine(command.platformSpecific)
3939
.also { it.workDirectory = runFrom }
4040
.also { it.environment.putAll(environment) }
4141
.createProcess()

lib/tasks/src/main/kotlin/dev/buijs/klutter/tasks/Executor.kt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,24 @@ import java.util.concurrent.TimeUnit
2929

3030
var executor: Executor = Executor()
3131

32-
infix fun String.execute(file: File) =
33-
executor.execute(
34-
runFrom = file,
35-
command = if(isWindows) "cmd.exe /c $this" else this)
32+
infix fun String. execute(file: File) =
33+
executor.execute(runFrom = file, command = this)
3634

3735
/**
3836
* Execute a CLI command.
3937
*/
4038
open class Executor {
4139

40+
val String.platformSpecific: List<String>
41+
get()= buildList {
42+
if(isWindows) {
43+
add("cmd.exe")
44+
add("/c")
45+
}
46+
47+
addAll(split(" "))
48+
}
49+
4250
/**
4351
* Execute a CLI command.
4452
*/
@@ -65,7 +73,7 @@ open class Executor {
6573
*/
6674
environment: Map<String,String> = emptyMap(),
6775
): String = ProcessBuilder()
68-
.command(command.split(" "))
76+
.command(command.platformSpecific)
6977
.directory(runFrom)
7078
.also { it.environment().putAll(environment)}
7179
.start()

0 commit comments

Comments
 (0)