mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-28 19:50:22 +08:00
🚧 WIP(custom): v3.0.0 migrate to vite and esm
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import path from 'path'
|
||||
import { app } from 'electron'
|
||||
import path from 'node:path'
|
||||
|
||||
import { getLogger } from '@core/utils/localLogger'
|
||||
import { app } from 'electron'
|
||||
|
||||
const STORE_PATH = app.getPath('userData')
|
||||
const LOG_PATH = path.join(STORE_PATH, 'piclist-gui-local.log')
|
||||
@@ -24,9 +24,9 @@ process.on('unhandledRejection', (error: any) => {
|
||||
})
|
||||
|
||||
// acconrding to https://github.com/Molunerfinn/PicGo/commit/7363be798cfef11e980934e542817ff1d6c04389#diff-896d0db4fbd446798fbffec14d456b4cd98d4c72c46856c770a585fa7ab0926f
|
||||
function bootstrapEPIPESuppression() {
|
||||
function bootstrapEPIPESuppression () {
|
||||
let suppressing = false
|
||||
function logEPIPEErrorOnce() {
|
||||
function logEPIPEErrorOnce () {
|
||||
if (suppressing) {
|
||||
return
|
||||
}
|
||||
@@ -35,8 +35,27 @@ function bootstrapEPIPESuppression() {
|
||||
handleProcessError('Detected EPIPE error; suppressing further EPIPE errors')
|
||||
}
|
||||
|
||||
require('epipebomb')(process.stdout, logEPIPEErrorOnce)
|
||||
require('epipebomb')(process.stderr, logEPIPEErrorOnce)
|
||||
epipeBomb(process.stdout, logEPIPEErrorOnce)
|
||||
epipeBomb(process.stderr, logEPIPEErrorOnce)
|
||||
}
|
||||
|
||||
bootstrapEPIPESuppression()
|
||||
|
||||
function epipeBomb (stream: any, callback: any) {
|
||||
if (stream == null) stream = process.stdout
|
||||
if (callback == null) callback = process.exit
|
||||
|
||||
function epipeFilter (err: any) {
|
||||
if (err.code === 'EPIPE') return callback()
|
||||
|
||||
// If there's more than one error handler (ie, us),
|
||||
// then the error won't be bubbled up anyway
|
||||
if (stream.listeners('error').length <= 1) {
|
||||
stream.removeAllListeners() // Pretend we were never here
|
||||
stream.emit('error', err) // Then emit as if we were never here
|
||||
stream.on('error', epipeFilter) // Then reattach, ready for the next error!
|
||||
}
|
||||
}
|
||||
|
||||
stream.on('error', epipeFilter)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user