mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-08 08:57:24 +08:00
use initPuppeteer to check if it has import correct
This commit is contained in:
@@ -14,7 +14,7 @@ ensureConfigFileExist()
|
|||||||
|
|
||||||
const isRunFromUi = Boolean(process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE)
|
const isRunFromUi = Boolean(process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE)
|
||||||
let puppeteer, StealthPlugin
|
let puppeteer, StealthPlugin
|
||||||
async function initPuppeteer () {
|
export async function initPuppeteer () {
|
||||||
// production
|
// production
|
||||||
if (
|
if (
|
||||||
isRunFromUi
|
isRunFromUi
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import DingtalkPlugin from '@bossgeekgo/dingtalk-plugin/index.mjs'
|
import DingtalkPlugin from '@bossgeekgo/dingtalk-plugin/index.mjs'
|
||||||
|
import { app } from 'electron'
|
||||||
import {
|
import {
|
||||||
SyncHook,
|
SyncHook,
|
||||||
AsyncSeriesHook
|
AsyncSeriesHook
|
||||||
@@ -11,13 +12,15 @@ const initPlugins = (hooks) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const runAutoChat = async () => {
|
export const runAutoChat = async () => {
|
||||||
let mainLoop
|
|
||||||
try {
|
try {
|
||||||
mainLoop = (await import('@bossgeekgo/geek-auto-start-chat-with-boss/index.mjs')).mainLoop
|
await (await import('@bossgeekgo/geek-auto-start-chat-with-boss/index.mjs')).initPuppeteer()
|
||||||
} catch {
|
} catch {
|
||||||
console.error(new Error('PUPPETEER_MAY_NOT_INSTALLED'))
|
console.error(new Error('PUPPETEER_MAY_NOT_INSTALLED'))
|
||||||
process.exit(1)
|
app.exit(1)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mainLoop = (await import('@bossgeekgo/geek-auto-start-chat-with-boss/index.mjs')).mainLoop
|
||||||
const hooks = {
|
const hooks = {
|
||||||
puppeteerLaunched: new SyncHook(),
|
puppeteerLaunched: new SyncHook(),
|
||||||
pageLoaded: new SyncHook(),
|
pageLoaded: new SyncHook(),
|
||||||
@@ -33,7 +36,10 @@ export const runAutoChat = async () => {
|
|||||||
try {
|
try {
|
||||||
await mainLoop(hooks)
|
await mainLoop(hooks)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
void err
|
console.log(err)
|
||||||
|
if(err instanceof Error && err.message.includes('ERR_MODULE_NOT_FOUND')) {
|
||||||
|
throw err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user