debug ts code

This commit is contained in:
pengfei.zhou
2019-10-22 18:01:10 +08:00
parent 2bf4874467
commit 44d7261c2c
14 changed files with 2733 additions and 12 deletions

21
remote/.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/index.ts",
"preLaunchTask": "tsc: build - tsconfig.json",
},
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229
}
]
}

View File

@@ -8,13 +8,14 @@ var context = vm.createContext(sandbox)
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
let messageObject = JSON.parse(message)
switch(messageObject.cmd) {
switch (messageObject.cmd) {
case "loadJS":
let result = vm.runInContext(messageObject.script, sandbox)
ws.send(JSON.stringify({cmd: 'loadJS', result: String(result)}))
ws.send(JSON.stringify({ cmd: 'loadJS', result: String(result) }))
break
case "evaluateJS":
break
}
})
})
})