From 98ae5a9d0e4025d1dfcaab58c29bf978160d7562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Tue, 12 Nov 2019 20:45:57 +0800 Subject: [PATCH] shell invoke debug --- doric-cli/scripts/server.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/doric-cli/scripts/server.js b/doric-cli/scripts/server.js index 191da4a1..5e20c283 100644 --- a/doric-cli/scripts/server.js +++ b/doric-cli/scripts/server.js @@ -1,5 +1,5 @@ const ws = require('nodejs-websocket') -const { spawn } = require('child_process') +const { exec, spawn } = require('child_process') const createServer = () => { let server = ws.createServer(connection => { @@ -12,7 +12,6 @@ const createServer = () => { let contextId = resultObject.data.contextId let projectHome = resultObject.data.projectHome console.log(projectHome) - { const code = spawn('code', [projectHome, projectHome + "/src/Snake.ts"]) code.stdout.on('data', (data) => { @@ -27,6 +26,21 @@ const createServer = () => { 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 }