Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
support local/remoreRoot for launch configs; fixes microsoft/vscode#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
weinand committed May 3, 2017
1 parent d23f786 commit 24ad94d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,16 @@
"description": "%node.restart.description%",
"default": true
},
"localRoot": {
"type": ["string", "null"],
"description": "%node.localRoot.description%",
"default": null
},
"remoteRoot": {
"type": ["string", "null"],
"description": "%node.remoteRoot.description%",
"default": null
},
"smartStep": {
"type": "boolean",
"description": "%smartStep.description%",
Expand Down Expand Up @@ -455,12 +465,12 @@
},
"localRoot": {
"type": ["string", "null"],
"description": "%node.attach.localRoot.description%",
"description": "%node.localRoot.description%",
"default": null
},
"remoteRoot": {
"type": ["string", "null"],
"description": "%node.attach.remoteRoot.description%",
"description": "%node.remoteRoot.description%",
"default": null
},
"smartStep": {
Expand Down
4 changes: 2 additions & 2 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"node.address.description": "TCP/IP address of process to be debugged (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.localRoot.description": "Path to the local directory containing the program.",
"node.remoteRoot.description": "Absolute path to the remote directory containing the program.",
"node.showAsyncStacks.description": "Show the async calls that led to the current call stack. 'inspector' protocol only.",

"node.launch.program.description": "Absolute path to the program. Generated value is guessed by looking at package.json and opened files. Edit this attribute.",
Expand All @@ -43,8 +45,6 @@
"node.launch.config.name": "Launch",

"node.attach.processId.description": "Id of process to attach to.",
"node.attach.localRoot.description": "Path to the local directory containing the program.",
"node.attach.remoteRoot.description": "Absolute path to the remote directory containing the program.",

"node.attach.config.name": "Attach",

Expand Down
36 changes: 18 additions & 18 deletions src/node/nodeDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ interface CommonArguments {
skipFiles?: string[];
/** Request frontend to restart session on termination. */
restart?: boolean;
/** Node's root directory. */
remoteRoot?: string;
/** VS Code's root directory. */
localRoot?: string;

// unofficial flags

Expand Down Expand Up @@ -295,10 +299,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 {
/** Node's root directory. */
remoteRoot?: string;
/** VS Code's root directory. */
localRoot?: string;
/** Send a USR1 signal to this process. */
processId?: string;
}
Expand Down Expand Up @@ -1151,6 +1151,20 @@ export class NodeDebugSession extends LoggingDebugSession {
this._restartMode = args.restart;
}

if (args.localRoot) {
const localRoot = args.localRoot;
if (!Path.isAbsolute(localRoot)) {
this.sendRelativePathErrorResponse(response, 'localRoot', localRoot);
return true;
}
if (!FS.existsSync(localRoot)) {
this.sendNotExistErrorResponse(response, 'localRoot', localRoot);
return true;
}
this._localRoot = localRoot;
}
this._remoteRoot = args.remoteRoot;

if (!this._sourceMaps) {
if (args.sourceMaps === undefined) {
args.sourceMaps = true;
Expand Down Expand Up @@ -1190,20 +1204,6 @@ export class NodeDebugSession extends LoggingDebugSession {
this._attachMode = true;
}

if (args.localRoot) {
const localRoot = args.localRoot;
if (!Path.isAbsolute(localRoot)) {
this.sendRelativePathErrorResponse(response, 'localRoot', localRoot);
return;
}
if (!FS.existsSync(localRoot)) {
this.sendNotExistErrorResponse(response, 'localRoot', localRoot);
return;
}
this._localRoot = localRoot;
}
this._remoteRoot = args.remoteRoot;

// if a processId is specified, try to bring the process into debug mode.
if (typeof args.processId === 'string') {
const pid_string = args.processId.trim();
Expand Down

0 comments on commit 24ad94d

Please sign in to comment.