Skip to content

Commit

Permalink
Merge pull request puremourning#59 from puremourning/node
Browse files Browse the repository at this point in the history
Support the Node.js debugger (not the legacy one)
  • Loading branch information
mergify[bot] authored Oct 6, 2019
2 parents 968a443 + 0b0388d commit ef675e0
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 0 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ on a best-efforts basis:
- Java (see caveats)
- C# (c-sharp) using dotnet core
- Go (requires separate installation of [Delve][])
- Node.js (requires node <12 for installation)

## Languages known not to work

Expand Down Expand Up @@ -160,6 +161,7 @@ The debug adapters themselves have certain runtime dependencies:
| C# (dotnet core) | Experimental | `--force-enable-csharp` | netcoredbg | DotNet core |
| C# (mono) | Experimental | `--force-enable-csharp` | vscode-mono-debug | Mono |
| Go | Experimental | `--enable-go` | vscode-go | Go, [Delve][] |
| Node.js | Experimental | `--force-enable-node` | vscode-node-debug2 | 6 < Node < 12, Npm |

For other languages, you'll need some other way to install the gadget.

Expand Down Expand Up @@ -605,6 +607,36 @@ Requires:
}
```

* Node.js

Requires:

* `install_gadget.py --force-enable-node`
* For installation, a Node.js environemt that is < node 12. I believe this is an
incompatibility with gulp. Advice, use [nvm][] with `nvm install --lts 10; nvm
use --lts 10; ./install_gadget.py --force-enable-node ...`

* Options described here:
https://code.visualstudio.com/docs/nodejs/nodejs-debugging

```json
{
"configurations": {
"run": {
"adapter": "vscode-node",
"configuration": {
"request": "launch",
"protocol": "auto",
"stopOnEntry": true,
"console": "integratedTerminal",
"program": "${workspaceRoot}/simple.js",
"cwd": "${workspaceRoot}"
}
}
}
}
```

Also the mock debugger, but that isn't actually useful.

## Partially supported
Expand Down
45 changes: 45 additions & 0 deletions install_gadget.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,25 @@
},
},
},
'vscode-node-debug2': {
'language': 'node',
'enabled': False,
'repo': {
'url': 'https://github.com/microsoft/vscode-node-debug2',
'ref': 'v1.39.1',
},
'do': lambda name, root: InstallNodeDebug( name, root ),
'adapters': {
'vscode-node': {
'name': 'node2',
'type': 'node2',
'command': [
'node',
'${gadgetDir}/vscode-node-debug2/out/src/nodeDebug.js'
]
},
},
},
}


Expand Down Expand Up @@ -279,6 +298,26 @@ def InstallTclProDebug( name, root ):
MakeSymlink( gadget_dir, name, root )


def InstallNodeDebug( name, root ):
node_version = subprocess.check_output( [ 'node', '--version' ] ).strip()
print( "Node.js version: {}".format( node_version ) )
if map( int, node_version[ 1: ].split( '.' ) ) >= [ 12, 0, 0 ]:
print( "Can't install vscode-debug-node2:" )
print( "Sorry, you appear to be running node 12 or later. That's not "
"compatible with the build system for this extension, and as far as "
"we know, there isn't a pre-built independent package." )
print( "My advice is to install nvm, then do:" )
print( " $ nvm install --lts 10" )
print( " $ nvm use --lts 10" )
print( " $ ./install_gadget.py --enable-node ..." )
raise RuntimeError( 'Invalid node environent for node debugger' )

with CurrentWorkingDir( root ):
subprocess.check_call( [ 'npm', 'install' ] )
subprocess.check_call( [ 'npm', 'run', 'build' ] )
MakeSymlink( gadget_dir, name, root )


def DownloadFileTo( url, destination, file_name = None, checksum = None ):
if not file_name:
file_name = url.split( '/' )[ -1 ]
Expand Down Expand Up @@ -396,6 +435,12 @@ def CloneRepoTo( url, ref, destination ):
RemoveIfExists( destination )
subprocess.check_call( [ 'git', 'clone', url, destination ] )
subprocess.check_call( [ 'git', '-C', destination, 'checkout', ref ] )
subprocess.check_call( [ 'git', 'submodule', 'sync', '--recursive' ] )
subprocess.check_call( [ 'git',
'submodule',
'update',
'--init',
'--recursive' ] )


OS = install.GetOS()
Expand Down
5 changes: 5 additions & 0 deletions support/test/node/simple/.tern-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": {
"node": {}
}
}
15 changes: 15 additions & 0 deletions support/test/node/simple/.vimspector.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"configurations": {
"run": {
"adapter": "vscode-node",
"configuration": {
"request": "launch",
"protocol": "auto",
"stopOnEntry": true,
"console": "integratedTerminal",
"program": "${workspaceRoot}/simple.js",
"cwd": "${workspaceRoot}"
}
}
}
}
3 changes: 3 additions & 0 deletions support/test/node/simple/simple.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var msg = 'Hello, world!'

console.log( "OK stuff happened" )

0 comments on commit ef675e0

Please sign in to comment.