diff --git a/.vscode/launch.json b/.vscode/launch.json index d1a0c579..b838ba80 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -23,6 +23,21 @@ "outFiles": [ "${workspaceRoot}/out/**/*.js" ], "internalConsoleOptions": "openOnSessionStart" }, + { + "type": "node", + "request": "launch", + "name": "Server (nodemon)", + "cwd": "${workspaceRoot}", + "runtimeExecutable": "npm", + "runtimeArgs": [ + "run-script", "nodemon" + ], + "restart": true, + "port": 5858, + "sourceMaps": true, + "outFiles": [ "${workspaceRoot}/out/**/*.js" ], + "console": "integratedTerminal" + }, { "type": "node", "request": "launch", @@ -38,15 +53,6 @@ "sourceMaps": true, "outFiles": [ "${workspaceRoot}/out/**/*.js" ], "internalConsoleOptions": "openOnSessionStart" - }, - { - "type": "node", - "request": "attach", - "name": "Nodemon Attach", - "restart": true, - "port": 5858, - "sourceMaps": true, - "outFiles": [ "${workspaceRoot}/out/**/*.js" ] } ], "compounds": [ diff --git a/package.json b/package.json index e6aa9096..9077ac6a 100644 --- a/package.json +++ b/package.json @@ -202,6 +202,11 @@ "description": "%node.timeout.description%", "default": 10000 }, + "restart": { + "type": "boolean", + "description": "%node.restart.description%", + "default": true + }, "smartStep": { "type": "boolean", "description": "%smartStep.description%", @@ -239,7 +244,7 @@ }, "restart": { "type": "boolean", - "description": "%node.attach.restart.description%", + "description": "%node.restart.description%", "default": true }, "sourceMaps": { diff --git a/package.nls.json b/package.nls.json index 4a1a0643..3fee8015 100644 --- a/package.nls.json +++ b/package.nls.json @@ -15,6 +15,7 @@ "node.port.description": "Debug port to attach to. Default is 5858.", "node.address.description": "TCP/IP address of debug port (for Node.js >= 5.0 only). Default is 'localhost'.", "node.timeout.description": "Retry for this number of milliseconds to connect to Node.js. Default is 10000 ms.", + "node.restart.description": "Restart session after Node.js has terminated.", "node.launch.program.description": "Absolute path to the program. Generated value is guessed by looking at package.json and opened files. Edit this attribute.", "node.launch.externalConsole.deprecationMessage": "Attribute 'externalConsole' is deprecated, use 'console' instead.", @@ -28,7 +29,6 @@ "node.launch.config.name": "Launch", "node.attach.processId.description": "Id of process to attach to.", - "node.attach.restart.description": "Restart session after Node.js has terminated.", "node.attach.localRoot.description": "The local source root that corresponds to the 'remoteRoot'.", "node.attach.remoteRoot.description": "The source root of the remote host.", diff --git a/src/node/nodeDebug.ts b/src/node/nodeDebug.ts index e329de05..21caae06 100644 --- a/src/node/nodeDebug.ts +++ b/src/node/nodeDebug.ts @@ -243,6 +243,8 @@ interface CommonArguments { smartStep?: boolean; /** automatically skip these files. */ skipFiles?: string[]; + /** Request frontend to restart session on termination. */ + restart?: boolean; // unofficial flags @@ -282,8 +284,6 @@ interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments, C * This interface should always match the schema found in the node-debug extension manifest. */ interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments, CommonArguments { - /** Request frontend to restart session on termination. */ - restart?: boolean; /** Node's root directory. */ remoteRoot?: string; /** VS Code's root directory. */ @@ -1019,6 +1019,10 @@ export class NodeDebugSession extends DebugSession { this._stopOnEntry = args.stopOnEntry; } + if (typeof args.restart === 'boolean') { + this._restartMode = args.restart; + } + if (!this._sourceMaps) { if (typeof args.sourceMaps === 'boolean' && args.sourceMaps) { const generatedCodeDirectory = args.outDir; @@ -1054,10 +1058,6 @@ export class NodeDebugSession extends DebugSession { this._attachMode = true; } - if (typeof args.restart === 'boolean') { - this._restartMode = args.restart; - } - if (args.localRoot) { const localRoot = args.localRoot; if (!Path.isAbsolute(localRoot)) {