From 063bfa79c26089707889ae8f5f552b1d0ad7b935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Wed, 11 Dec 2019 15:14:29 +0800 Subject: [PATCH] debug by pass reload --- scripts/server.js | 9 ++++++--- scripts/watcher.js | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) 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)