Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make the launch.json generation leaner #618

Merged
merged 2 commits into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions configureWorkspace/configDebugProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,14 @@ import * as vscode from 'vscode';
export class DockerDebugConfigProvider implements vscode.DebugConfigurationProvider {

public provideDebugConfigurations(folder: vscode.WorkspaceFolder | undefined, token?: vscode.CancellationToken): vscode.ProviderResult<vscode.DebugConfiguration[]> {

const config: vscode.DebugConfiguration = {
name: 'Docker: Attach to Node',
type: 'node',
request: 'attach',
port: 9229,
address: 'localhost',
localRoot: '\${workspaceFolder}',
remoteRoot: '/usr/src/app',
protocol: 'inspector'
};

return [config];

return vscode.window.showInputBox({ value: '/usr/src/app', prompt: 'Please enter your Docker remote root'}).then(remoteRoot => {
return [{
name: 'Docker: Attach to Node',
type: 'node',
request: 'attach',
remoteRoot
}];
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For any new code added, we tend to avoid thenable in favor of async-await.

Debugging this code has seemed easier when the code is written as :

let remoteRoot = await vscode.window.showInputBox({ value: '/usr/src/app', prompt: 'Please enter your Docker remote root'}); 
return [{
name: 'Docker: Attach to Node',
type: 'node',
request: 'attach',
remoteRoot
}]; 

You would need to make the function async however, so I'll defer to @StephenWeatherford whether requiring this standard is worth it here. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please do convert. Also, please use ext.ui.showInputBox instead of vscode.window.showInputBox. Note that this will throw on user cancel, which I assume makes sense here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review and suggestions I have pushed a commit which takes care of this.

}

}
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,7 @@
"type": "node",
"request": "attach",
"name": "Docker: Attach to Node",
"port": 9229,
"address": "localhost",
"localRoot": "^\"\\${workspaceFolder}\"",
"remoteRoot": "/usr/src/app",
"protocol": "inspector"
"remoteRoot": "/usr/src/app"
}
}
]
Expand Down