launch vscode via child process

This commit is contained in:
王劲鹏 2019-11-12 16:43:30 +08:00
parent 1ab3fdb3ea
commit 40bcdd6898

View File

@ -1,4 +1,5 @@
const ws = require('nodejs-websocket') const ws = require('nodejs-websocket')
const { spawn } = require('child_process')
const createServer = () => { const createServer = () => {
let server = ws.createServer(connection => { let server = ws.createServer(connection => {
@ -11,6 +12,19 @@ const createServer = () => {
let contextId = resultObject.data.contextId let contextId = resultObject.data.contextId
let projectHome = resultObject.data.projectHome let projectHome = resultObject.data.projectHome
console.log(projectHome) console.log(projectHome)
const code = spawn('code', [projectHome])
code.stdout.on('data', (data) => {
console.log(`stdout: ${data}`)
})
code.stderr.on('data', (data) => {
console.error(`stderr: ${data}`)
})
code.on('close', (code) => {
console.log(`child process exited with code ${code}`)
});
break break
} }
}) })