shell invoke debug

This commit is contained in:
王劲鹏 2019-11-12 20:45:57 +08:00
parent cdde8c9c3d
commit 98ae5a9d0e

View File

@ -1,5 +1,5 @@
const ws = require('nodejs-websocket') const ws = require('nodejs-websocket')
const { spawn } = require('child_process') const { exec, spawn } = require('child_process')
const createServer = () => { const createServer = () => {
let server = ws.createServer(connection => { let server = ws.createServer(connection => {
@ -12,7 +12,6 @@ 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, projectHome + "/src/Snake.ts"]) const code = spawn('code', [projectHome, projectHome + "/src/Snake.ts"])
code.stdout.on('data', (data) => { code.stdout.on('data', (data) => {
@ -27,6 +26,21 @@ const createServer = () => {
console.log(`child process exited with code ${code}`) console.log(`child process exited with code ${code}`)
}) })
} }
{
setTimeout(() => {
exec('osascript -e \'tell application "System Events"\ntell application "Visual Studio Code" to activate\nkey code 96\nend tell\'', (err, stdout, stderr) => {
if (err) {
// node couldn't execute the command
console.log(`stdout: ${err}`)
return;
}
// the *entire* stdout and stderr (buffered)
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
})
}, 4000)
}
break break
} }