Sublime Forum

Use ctrl+b to open build window if running

#1

I have a build script that runs nodemon. Often the build window goes away, and I forget nodemon is running. If I push ctrl+b again, it causes a new node.exe to launch, with errors, and then the node processes have to be killed through Task Manager. I’ve added these two commands to help with killing the build process and to show the build window:

{"keys": "pause"], "command": "exec", "args": {"kill": true} }, {"keys": "ctrl+shift+b"], "command": "show_panel", "args": {"panel": "output.exec"}} ]
That’s an improvement, but what would be even better is if when I push ctrl+b, rather than running nodemon again, I would like to check if nodemon is running, i.e. the build has not been killed yet, and if it’s running, show the build panel, otherwise, launch the build (and show the panel). Is there a way to do this?

0 Likes

#2

This is a similar question to Build system for Python

0 Likes

#3

@prmaple: No, it’s not. At all.

@kobenauf: The first issue you are describing is a result of a weird implementation of the exec command, which is that a previously running process is only killed when it sends something to its stdout and a new build process has been started already. I don’t know why it does that, but well, whatever. It is fixable if you patch the bundled Default/exec.py and know some Python.

The second request is a bit more complex. What you are requesting can be done either by, again, patching exec.py and adding another parameter that will open the panel if the panel if a process is still running, or by writing a different plugin that will attempt to hack into the running exec command to read the process handle from there and do approproate actions, i.e. show the panel or execute a new build.

So yes, there are ways to do both, actually. Sorry I didn’t include the exact code changes though, since I didn’t have that time.

0 Likes

#4

Right. My bad.
Congrats on your 1024th post. :smiley:

I was thinking that this problem could use the similar solution/workaround, a separate command that checks the running processes and decides what to do next.

0 Likes