wk-j / vscode-save-and-run

Visual Studio Code extension to run commands whenever a file is saved https://marketplace.visualstudio.com/items?itemName=wk-j.save-and-run
Apache License 2.0
32 stars 7 forks source link

How to use this to restart a continuously running process? #22

Open nielmond opened 5 years ago

nielmond commented 5 years ago

I want to restart a server, something like this https://stackoverflow.com/questions/35248007/vscode-editor-restart-nodejs-server-when-file-is-changed, but more generic.

Maybe there is a way to send a SIGINT?

nielmond commented 5 years ago

Actually I found this works

"saveAndRun": {
    "commands": [
      {
        "match": "\\.whatever$",
        "cmd": "\u0003",
        "useShortcut": false,
        "silent": false
      },
      {
        "match": "\\.whatever$",
        "cmd": "<start server command>",
        "useShortcut": false,
        "silent": false
      }
    ]
  }

The \u0003 command kills whatever is running. Chaining the commands with && didn't work (maybe I wasn't escaping it correctly), but two separate entries well enough.

Maybe there's a more elegant way? If not, feel free to close this.