debug by pass reload
This commit is contained in:
parent
7981ff0851
commit
063bfa79c2
@ -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)
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user