正在显示
2 个修改的文件
包含
27 行增加
和
3 行删除
| ... | @@ -5,6 +5,7 @@ const electron = require('electron') | ... | @@ -5,6 +5,7 @@ const electron = require('electron') |
| 5 | const path = require('path') | 5 | const path = require('path') |
| 6 | const { say } = require('cfonts') | 6 | const { say } = require('cfonts') |
| 7 | const { spawn } = require('child_process') | 7 | const { spawn } = require('child_process') |
| 8 | +const config = require('../config') | ||
| 8 | const webpack = require('webpack') | 9 | const webpack = require('webpack') |
| 9 | const WebpackDevServer = require('webpack-dev-server') | 10 | const WebpackDevServer = require('webpack-dev-server') |
| 10 | const webpackHotMiddleware = require('webpack-hot-middleware') | 11 | const webpackHotMiddleware = require('webpack-hot-middleware') |
| ... | @@ -37,6 +38,28 @@ function logStats(proc, data) { | ... | @@ -37,6 +38,28 @@ function logStats(proc, data) { |
| 37 | console.log(log) | 38 | console.log(log) |
| 38 | } | 39 | } |
| 39 | 40 | ||
| 41 | +function removeJunk(chunk) { | ||
| 42 | + if (config.dev.removeElectronJunk) { | ||
| 43 | + // Example: 2018-08-10 22:48:42.866 Electron[90311:4883863] *** WARNING: Textured window <AtomNSWindow: 0x7fb75f68a770> | ||
| 44 | + if (/\d+-\d+-\d+ \d+:\d+:\d+\.\d+ Electron(?: Helper)?\[\d+:\d+] /.test(chunk)) { | ||
| 45 | + return false; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + // Example: [90789:0810/225804.894349:ERROR:CONSOLE(105)] "Uncaught (in promise) Error: Could not instantiate: ProductRegistryImpl.Registry", source: chrome-devtools://devtools/bundled/inspector.js (105) | ||
| 49 | + if (/\[\d+:\d+\/|\d+\.\d+:ERROR:CONSOLE\(\d+\)\]/.test(chunk)) { | ||
| 50 | + return false; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + // Example: ALSA lib confmisc.c:767:(parse_card) cannot find card '0' | ||
| 54 | + if (/ALSA lib [a-z]+\.c:\d+:\([a-z_]+\)/.test(chunk)) { | ||
| 55 | + return false; | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + | ||
| 60 | + return chunk; | ||
| 61 | +} | ||
| 62 | + | ||
| 40 | function startRenderer() { | 63 | function startRenderer() { |
| 41 | return new Promise((resolve) => { | 64 | return new Promise((resolve) => { |
| 42 | rendererConfig.entry.renderer = [path.join(__dirname, 'dev-client')].concat(rendererConfig.entry.renderer) | 65 | rendererConfig.entry.renderer = [path.join(__dirname, 'dev-client')].concat(rendererConfig.entry.renderer) |
| ... | @@ -128,10 +151,10 @@ function startElectron() { | ... | @@ -128,10 +151,10 @@ function startElectron() { |
| 128 | electronProcess = spawn(electron, args) | 151 | electronProcess = spawn(electron, args) |
| 129 | 152 | ||
| 130 | electronProcess.stdout.on('data', data => { | 153 | electronProcess.stdout.on('data', data => { |
| 131 | - electronLog(data, 'blue') | 154 | + electronLog(removeJunk(data), 'blue') |
| 132 | }) | 155 | }) |
| 133 | electronProcess.stderr.on('data', data => { | 156 | electronProcess.stderr.on('data', data => { |
| 134 | - electronLog(data, 'red') | 157 | + electronLog(removeJunk(data), 'red') |
| 135 | }) | 158 | }) |
| 136 | 159 | ||
| 137 | electronProcess.on('close', () => { | 160 | electronProcess.on('close', () => { | ... | ... |
-
请 注册 或 登录 后发表评论