Skip to content

Commit ab23c1f

Browse files
committed
fix: exec command have deprecated, use ProcessBuilder on windows
1 parent 2e315c7 commit ab23c1f

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pluginSinceBuild = 222
1212

1313
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
1414
platformType = GO
15-
platformVersion = 2024.2
15+
platformVersion = LATEST-EAP-SNAPSHOT
1616

1717
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
1818
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22

src/main/kotlin/com/github/oldmegit/goframehelper/listener/Listener.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,20 @@ class Listener(private val project: Project): BulkFileListener {
4646
return
4747
}
4848

49+
val workDir = project.basePath
50+
4951
// exec command based on different systems
5052
val os = System.getProperty("os.name").lowercase(Locale.getDefault())
51-
val process = if (os.contains("windows")) {
52-
Runtime.getRuntime().exec(commandRaw, null, File(project.basePath.toString()))
53+
val command = if (os.contains("windows")) {
54+
arrayOf("cmd", "/c", "cd $workDir && $commandRaw")
5355
} else if (os.contains("linux") || os.contains("mac")) {
54-
val workDir = project.basePath
55-
val command = arrayOf("sh", "-c", "cd $workDir && $commandRaw")
56-
ProcessBuilder(*command).start()
56+
arrayOf("sh", "-c", "cd $workDir && $commandRaw")
5757
} else {
5858
Notification.message(project, Bundle.getMessage("fileWatch.NotSupport"))
5959
return
6060
}
6161

62+
val process = ProcessBuilder(*command).start()
6263
val code = process.waitFor()
6364
if (code != 0) {
6465
throw Exception(code.toString())

0 commit comments

Comments
 (0)