@@ -5,12 +5,14 @@ import com.github.oldmegit.goframehelper.gf.Gf
5
5
import com.github.oldmegit.goframehelper.gf.GfGoMod
6
6
import com.github.oldmegit.goframehelper.ui.AppSettingsState
7
7
import com.goide.GoFileType
8
+ import com.intellij.notification.NotificationGroupManager
9
+ import com.intellij.notification.NotificationType
8
10
import com.intellij.openapi.project.Project
9
11
import com.intellij.openapi.vfs.newvfs.BulkFileListener
10
12
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
11
- import com.intellij.notification.NotificationGroupManager
12
- import com.intellij.notification.NotificationType
13
13
import java.io.File
14
+ import java.util.*
15
+
14
16
15
17
class Listener (private val project : Project ): BulkFileListener {
16
18
override fun after (events : MutableList <out VFileEvent >) {
@@ -29,12 +31,26 @@ class Listener(private val project: Project): BulkFileListener {
29
31
return
30
32
}
31
33
32
- val runtime = Runtime .getRuntime()
33
34
try {
34
- if (Gf .isApiFile(project, file) && Gf .enableApiWatch(project)) {
35
- runtime.exec( Gf .gfGenCtrl(project), null , File (project.basePath.toString()) )
35
+ var command = if (Gf .isApiFile(project, file) && Gf .enableApiWatch(project)) {
36
+ Gf .gfGenCtrl(project)
36
37
} else if (Gf .isLogicFile(project, file) && Gf .enableLogicWatch(project)) {
37
- runtime.exec(Gf .gfGenService(project), null , File (project.basePath.toString()))
38
+ Gf .gfGenService(project)
39
+ } else {
40
+ return
41
+ }
42
+
43
+ val os = System .getProperty(" os.name" ).lowercase(Locale .getDefault())
44
+ if (os.contains(" windows" )) {
45
+ command = " cmd /c $command "
46
+ } else if (os.contains(" linux" ) || os.contains(" mac" )) {
47
+ command = " /bin/sh -c $command "
48
+ }
49
+
50
+ val process = Runtime .getRuntime().exec(command, null , File (project.basePath.toString()))
51
+ val code = process.waitFor()
52
+ if (code != 0 ) {
53
+ throw Exception (" execute command fail" )
38
54
}
39
55
} catch (_: Exception ) {
40
56
val message = Bundle .getMessage(" gfExecErrNotify" )
0 commit comments