@@ -32,7 +32,7 @@ class Listener(private val project: Project): BulkFileListener {
3232 }
3333
3434 try {
35- var command = if (Gf .isApiFile(project, file) && Gf .enableApiWatch(project)) {
35+ val commandRaw = if (Gf .isApiFile(project, file) && Gf .enableApiWatch(project)) {
3636 Gf .gfGenCtrl(project)
3737 } else if (Gf .isLogicFile(project, file) && Gf .enableLogicWatch(project)) {
3838 Gf .gfGenService(project)
@@ -41,26 +41,28 @@ class Listener(private val project: Project): BulkFileListener {
4141 }
4242
4343 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()))
4646 } 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" ))
4852 }
4953
50- val process = Runtime .getRuntime().exec(command, null , File (project.basePath.toString()))
5154 val code = process.waitFor()
5255 if (code != 0 ) {
53- throw Exception (" execute command fail " )
56+ throw Exception (Bundle .getMessage( " gfExecErrNotify " ) )
5457 }
55- } catch (_: Exception ) {
56- val message = Bundle .getMessage(" gfExecErrNotify" )
58+ } catch (e: Exception ) {
5759 val settings = AppSettingsState .getInstance(project)
5860 settings.gfEnableApiWatch = false
5961 settings.gfEnableLogicWatch = false
6062
6163 NotificationGroupManager .getInstance()
6264 .getNotificationGroup(" GoFrame Help Notify" )
63- .createNotification(message , NotificationType .INFORMATION )
65+ .createNotification(e.toString() , NotificationType .INFORMATION )
6466 .notify(project)
6567 }
6668 }
0 commit comments