@@ -32,7 +32,7 @@ class Listener(private val project: Project): BulkFileListener {
32
32
}
33
33
34
34
try {
35
- var command = if (Gf .isApiFile(project, file) && Gf .enableApiWatch(project)) {
35
+ val commandRaw = if (Gf .isApiFile(project, file) && Gf .enableApiWatch(project)) {
36
36
Gf .gfGenCtrl(project)
37
37
} else if (Gf .isLogicFile(project, file) && Gf .enableLogicWatch(project)) {
38
38
Gf .gfGenService(project)
@@ -41,26 +41,28 @@ class Listener(private val project: Project): BulkFileListener {
41
41
}
42
42
43
43
val os = System .getProperty(" os.name" ).lowercase(Locale .getDefault())
44
- if (os.contains(" windows" )) {
45
- command = " cmd /c $command "
44
+ val process = if (os.contains(" windows" )) {
45
+ Runtime .getRuntime().exec(commandRaw, null , File (project.basePath.toString()))
46
46
} else if (os.contains(" linux" ) || os.contains(" mac" )) {
47
- command = " /bin/sh -c $command "
47
+ val workDir = project.basePath
48
+ val command = arrayOf(" sh" , " -c" , " cd $workDir && $commandRaw " )
49
+ ProcessBuilder (* command).start()
50
+ } else {
51
+ throw Exception (Bundle .getMessage(" gfExecNotSupport" ))
48
52
}
49
53
50
- val process = Runtime .getRuntime().exec(command, null , File (project.basePath.toString()))
51
54
val code = process.waitFor()
52
55
if (code != 0 ) {
53
- throw Exception (" execute command fail " )
56
+ throw Exception (Bundle .getMessage( " gfExecErrNotify " ) )
54
57
}
55
- } catch (_: Exception ) {
56
- val message = Bundle .getMessage(" gfExecErrNotify" )
58
+ } catch (e: Exception ) {
57
59
val settings = AppSettingsState .getInstance(project)
58
60
settings.gfEnableApiWatch = false
59
61
settings.gfEnableLogicWatch = false
60
62
61
63
NotificationGroupManager .getInstance()
62
64
.getNotificationGroup(" GoFrame Help Notify" )
63
- .createNotification(message , NotificationType .INFORMATION )
65
+ .createNotification(e.toString() , NotificationType .INFORMATION )
64
66
.notify(project)
65
67
}
66
68
}
0 commit comments