mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-07 16:37:06 +08:00
WIP: use fs.WriteStream to replace net.Socket to fix stdio data event not trigger on windows TODO: the content expect no print seems printed to stdout, normal JSON mix with console.log, may cause download process of puppeteer interrupted (near 44%)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { app } from 'electron'
|
import { app } from 'electron'
|
||||||
import checkAndDownloadPuppeteerExecutable from './check-and-download-puppeteer-executable'
|
import checkAndDownloadPuppeteerExecutable from './check-and-download-puppeteer-executable'
|
||||||
import * as net from 'net'
|
import * as fs from 'fs'
|
||||||
import { pipeWriteRegardlessError } from '../utils/pipe'
|
import { pipeWriteRegardlessError } from '../utils/pipe'
|
||||||
|
|
||||||
export enum DOWNLOAD_ERROR_EXIT_CODE {
|
export enum DOWNLOAD_ERROR_EXIT_CODE {
|
||||||
@@ -10,9 +10,9 @@ export enum DOWNLOAD_ERROR_EXIT_CODE {
|
|||||||
export const checkAndDownloadDependenciesForInit = async () => {
|
export const checkAndDownloadDependenciesForInit = async () => {
|
||||||
process.on('disconnect', () => app.exit())
|
process.on('disconnect', () => app.exit())
|
||||||
app.dock?.hide()
|
app.dock?.hide()
|
||||||
let pipe: null | net.Socket = null
|
let pipe: null | fs.WriteStream = null
|
||||||
try {
|
try {
|
||||||
pipe = new net.Socket({ fd: 3 })
|
pipe = fs.createWriteStream(null, { fd: 3 })
|
||||||
} catch {
|
} catch {
|
||||||
console.warn('pipe is not available')
|
console.warn('pipe is not available')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import DingtalkPlugin from '@geekgeekrun/dingtalk-plugin/index.mjs'
|
|||||||
import { app } from 'electron'
|
import { app } from 'electron'
|
||||||
import { SyncHook, AsyncSeriesHook } from 'tapable'
|
import { SyncHook, AsyncSeriesHook } from 'tapable'
|
||||||
import { readConfigFile } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
import { readConfigFile } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
||||||
import * as net from 'net'
|
import * as fs from 'fs'
|
||||||
import {
|
import {
|
||||||
checkPuppeteerExecutable,
|
checkPuppeteerExecutable,
|
||||||
} from './CHECK_AND_DOWNLOAD_DEPENDENCIES/check-and-download-puppeteer-executable'
|
} from './CHECK_AND_DOWNLOAD_DEPENDENCIES/check-and-download-puppeteer-executable'
|
||||||
@@ -26,9 +26,9 @@ export const runAutoChat = async () => {
|
|||||||
app.exit()
|
app.exit()
|
||||||
})
|
})
|
||||||
app.dock?.hide()
|
app.dock?.hide()
|
||||||
let pipe: null | net.Socket = null
|
let pipe: null | fs.WriteStream = null
|
||||||
try {
|
try {
|
||||||
pipe = new net.Socket({ fd: 3 })
|
pipe = fs.createWriteStream(null, { fd: 3 })
|
||||||
} catch {
|
} catch {
|
||||||
console.warn('pipe is not available')
|
console.warn('pipe is not available')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
import * as net from 'net'
|
import * as fs from 'fs'
|
||||||
|
|
||||||
export const pipeWriteRegardlessError = (
|
export const pipeWriteRegardlessError = async (
|
||||||
pipe: net.Socket | null,
|
pipe: fs.WriteStream | null,
|
||||||
...writeArgs: Parameters<net.Socket['write']>
|
chunk: unknown,
|
||||||
|
option?
|
||||||
) => {
|
) => {
|
||||||
try {
|
return new Promise((resolve) => {
|
||||||
pipe?.write(...writeArgs)
|
// debugger
|
||||||
} catch (error) {
|
pipe?.write(chunk, option, (error) => {
|
||||||
console.log('pipe.write Error', error)
|
if (error) {
|
||||||
}
|
console.log('pipe.write Error', error)
|
||||||
|
}
|
||||||
|
resolve(undefined)
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user