use initPuppeteer to check if it has import correct

This commit is contained in:
bossgeekgo
2024-02-14 11:56:26 +08:00
parent a2c70add1c
commit 1854059761
2 changed files with 11 additions and 5 deletions

View File

@@ -14,7 +14,7 @@ ensureConfigFileExist()
const isRunFromUi = Boolean(process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE)
let puppeteer, StealthPlugin
async function initPuppeteer () {
export async function initPuppeteer () {
// production
if (
isRunFromUi

View File

@@ -1,4 +1,5 @@
import DingtalkPlugin from '@bossgeekgo/dingtalk-plugin/index.mjs'
import { app } from 'electron'
import {
SyncHook,
AsyncSeriesHook
@@ -11,13 +12,15 @@ const initPlugins = (hooks) => {
}
export const runAutoChat = async () => {
let mainLoop
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 {
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 = {
puppeteerLaunched: new SyncHook(),
pageLoaded: new SyncHook(),
@@ -33,7 +36,10 @@ export const runAutoChat = async () => {
try {
await mainLoop(hooks)
} catch (err) {
void err
console.log(err)
if(err instanceof Error && err.message.includes('ERR_MODULE_NOT_FOUND')) {
throw err
}
}
}
}