feat:protect debug error

This commit is contained in:
pengfei.zhou 2019-12-02 10:47:29 +08:00
parent d24b8a1789
commit ebfcbdec15
2 changed files with 13 additions and 11 deletions

View File

@ -26,9 +26,7 @@ function fromDir(startPath, filter) {
}; };
}; };
function doMerge(startPath, fileName) { function doMerge(startPath, fileName) {
// console.log('-- found: ', startPath, fileName);
const filePath = fileName ? path.join(startPath, fileName) : startPath const filePath = fileName ? path.join(startPath, fileName) : startPath
// console.log('-- merge: ', filePath.replace(/bundle\//, 'build/'), filePath)
const mergedMap = SourceMapMerger.createMergedSourceMapFromFiles([ const mergedMap = SourceMapMerger.createMergedSourceMapFromFiles([
filePath.replace(/bundle\//, 'build/'), filePath.replace(/bundle\//, 'build/'),
filePath, filePath,

View File

@ -16,6 +16,7 @@ setTimeout(() => {
fs.readFile(path, 'utf-8', (error, data) => { fs.readFile(path, 'utf-8', (error, data) => {
if (!path.endsWith('.map')) { if (!path.endsWith('.map')) {
console.log('File change:', path) console.log('File change:', path)
try {
const sourceMap = doMerge(path + ".map") const sourceMap = doMerge(path + ".map")
ws.connections.forEach(e => { ws.connections.forEach(e => {
e.sendText(JSON.stringify({ e.sendText(JSON.stringify({
@ -25,6 +26,9 @@ setTimeout(() => {
sourceMap, sourceMap,
})) }))
}) })
} catch (e) {
console.error(e)
}
} }
}) })
}); });