Skip to content

Commit 7d60681

Browse files
authoredJun 1, 2020
chore: add a base VSCode config (aws#8184)
VSCode configs for our repo are tricky enough that people would benefit from having them checked into the repo. Some people are strongly opposed to having them checked in at the default location though, for what I assume are the following reasons: - There's no good way to have user-specific, workspace-specific preferences, so one set of `.vscode` files would apply to everyone. - If you already had workspace-specific VSCode preferences, the new files would collide. - Not everyone uses VSCode, so if we start adding `.vscode` files, we should also start adding `.idea` files and others, and where will it end, and who's going to keep them consistent? As a compromise, adding a script which will copy a base VSCode config into place. You can choose the run the script if you want it, and you can choose not to run it if you don't. Everybody happy, right? If necessary, we'll be able to extend this in the future with custom per-user configs, but for now let's start with something simple. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 1755cf2 commit 7d60681

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed
 

‎.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# VSCode extension
2-
.vscode/
2+
3+
# Store launch config in repo but not settings
4+
.vscode/settings.json
35
/.favorites.json
46

57
# TypeScript incremental build states

‎.vscode/launch.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
// Has convenient settings for attaching to a NodeJS process for debugging purposes
9+
// that are NOT the default and otherwise every developers has to configure for
10+
// themselves again and again.
11+
"type": "node",
12+
"request": "attach",
13+
"name": "Attach to NodeJS",
14+
// If we don't do this, every step-into into an async function call will go into
15+
// NodeJS internals which are hard to step out of.
16+
"skipFiles": [
17+
"<node_internals>/**"
18+
],
19+
// Saves some button-pressing latency on attaching
20+
"stopOnEntry": false
21+
}
22+
]
23+
}

‎CONTRIBUTING.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ and let us know if it's not up-to-date (even better, submit a PR with your corr
4343
- [Troubleshooting](#troubleshooting)
4444
- [Debugging](#debugging)
4545
- [Connecting the VS Code Debugger](#connecting-the-vs-code-debugger)
46+
- [Run a CDK unit test in the debugger](#run-a-cdk-unit-test-in-the-debugger)
4647
- [Related Repositories](#related-repositories)
4748

4849
## Getting Started
@@ -327,7 +328,7 @@ All packages in the repo use a standard base configuration found at [eslintrc.js
327328
This can be customized for any package by modifying the `.eslintrc` file found at its root.
328329

329330
If you're using the VS Code and would like to see eslint violations on it, install the [eslint
330-
extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint).
331+
extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint).
331332

332333
#### pkglint
333334

@@ -910,6 +911,24 @@ To debug your CDK application along with the CDK repository,
910911
6. The debug view, should now have a launch configuration called 'Debug hello-cdk' and launching that will start the debugger.
911912
7. Any time you modify the CDK app or any of the CDK modules, they need to be re-built and depending on the change the `link-all.sh` script from step#2, may need to be re-run. Only then, would VS code recognize the change and potentially the breakpoint.
912913

914+
### Run a CDK unit test in the debugger
915+
916+
If you want to run the VSCode debugger on unit tests of the CDK project
917+
itself, do the following:
918+
919+
1. Set a breakpoint inside your unit test.
920+
2. In your terminal, depending on the type of test, run either:
921+
922+
```
923+
# (For tests names test.xxx.ts)
924+
$ node --inspect-brk /path/to/aws-cdk/node_modules/.bin/nodeunit -t 'TESTNAME'
925+
926+
# (For tests names xxxx.test.ts)
927+
$ node --inspect-brk /path/to/aws-cdk/node_modules/.bin/jest -i -t 'TESTNAME'
928+
```
929+
930+
3. On the `Run` pane of VSCode, select the run configuration **Attach to NodeJS** and click the button.
931+
913932
## Related Repositories
914933

915934
* [Samples](https://github.com/aws-samples/aws-cdk-examples): includes sample code in multiple languages

0 commit comments

Comments
 (0)
Please sign in to comment.