diff --git a/scripts/server.js b/scripts/server.js index a4bf7867..614b83ac 100644 --- a/scripts/server.js +++ b/scripts/server.js @@ -2,18 +2,18 @@ const ws = require('nodejs-websocket') const { exec, spawn } = require('child_process') const fs = require('fs') +var server var contextId = null var clientConnection = null var debuggerConnection = null const createServer = () => { - let server = ws.createServer(connection => { + server = ws.createServer(connection => { console.log('connected', connection.headers.host) if (connection.headers.host.startsWith("localhost")) { console.log("debugger " + connection.key + " attached to dev kit") debuggerConnection = connection - clientConnection.sendText(JSON.stringify({ cmd: 'SWITCH_TO_DEBUG', contextId: contextId @@ -30,7 +30,8 @@ const createServer = () => { switch(resultObject.cmd) { case 'DEBUG': clientConnection = connection - + server.debugging = true + console.log("enter debugging") contextId = resultObject.data.contextId let projectHome = '.' @@ -56,6 +57,8 @@ const createServer = () => { }) connection.on('close', function (code) { console.log('close: code = ' + code, connection.key) + console.log("quit debugging") + server.debugging = false }) connection.on('error', function (code) { console.log('error', code) diff --git a/scripts/watcher.js b/scripts/watcher.js index f1900464..9970f8ef 100644 --- a/scripts/watcher.js +++ b/scripts/watcher.js @@ -13,6 +13,10 @@ setTimeout(() => { chokidar.watch(process.cwd() + "/bundle", { ignored: /(^|[\/\\])\../, }).on('change', (path) => { + if (ws.debugging) { + console.log("debugging, hot reload by pass") + return + } fs.readFile(path, 'utf-8', (error, data) => { if (!path.endsWith('.map')) { console.log('File change:', path)