سؤال

I'm running a web server with dart, it starts by:

dart server.dart

When I modified the project files, I hope this server can be restarted automatically. Is there any way to do it? Or is there any useful tool can help?

هل كانت مفيدة؟

المحلول

Not natively in Dart until bug 3310 is implemented. There may well be external tools that will restart the command line when a file changes (open to other answers).

نصائح أخرى

Just ran into this problem developing a dart server. For vscode IDE, following this stackoverflow suggestion I installed the Save and Run Ext extension and modified it for a dart command line program:

{
  "saveAndRunExt": {
    "commands": [
      {
        // "match": "\\.(css$|js$|html$)",
        "match": ".dart$",
        "isShellCommand": false,
        "cmd": "workbench.action.debug.restart",
        "isAsync": false
      },
      {
        "match": ".dart$",
        "isShellCommand": false,
        "cmd": "dart.rerunLastTestDebugSession"
      }
    ]
  }
}

This will restart the server in debug mode and rerun the last test debug session if any dart file is saved. Both server and test debug sessions work. Works great for me, at least on initial use of this extension.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top