change puppeteer import path for ui project - always use the one in home folder

This commit is contained in:
bossgeekgo
2024-02-15 00:54:19 +08:00
parent 6c70993d97
commit 78118751b1
3 changed files with 6 additions and 18 deletions

View File

@@ -2,7 +2,6 @@ import * as path from 'node:path'
import * as os from 'node:os'
import * as fs from 'node:fs'
import type { InstalledBrowser } from '@puppeteer/browsers'
import { isDev } from '../../runtimeDesidedEnv'
const expectBuildId = process.env.EXPECT_CHROME_FOR_PUPPETEER_BUILD_ID || '121.0.6167.85'
const cacheDir = path.join(
@@ -13,15 +12,10 @@ const cacheDir = path.join(
)
const getPuppeteerManagerModule = async () => {
if (!isDev) {
const runtimeDependencies = await import(
path.join(os.homedir(), '.bossgeekgo', 'external-node-runtime-dependencies/index.mjs')
)
return runtimeDependencies.puppeteerManager
} else {
const importResult = await import('@puppeteer/browsers')
return importResult
}
const runtimeDependencies = await import(
path.join(os.homedir(), '.bossgeekgo', 'external-node-runtime-dependencies/index.mjs')
)
return runtimeDependencies.puppeteerManager
}
export const getExpectPuppeteerExecutablePath = async () => {

View File

@@ -1 +0,0 @@
export const isDev = process.env.NODE_ENV === 'development'

View File

@@ -9,7 +9,6 @@ import {
writeConfigFile
} from '@bossgeekgo/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
import { ChildProcess } from 'child_process'
import { isDev } from '../runtimeDesidedEnv'
import { getExpectPuppeteerExecutablePath } from '../flow/CHECK_AND_DOWNLOAD_DEPENDENCIES/check-and-download-puppeteer'
let mainWindow: BrowserWindow
@@ -90,12 +89,8 @@ export function createMainWindow(): void {
const subProcessEnv = {
...process.env,
MAIN_BOSSGEEKGO_UI_RUN_MODE: 'geekAutoStartWithBoss'
}
if (!isDev) {
Object.assign(subProcessEnv, {
PUPPETEER_EXECUTABLE_PATH: await getExpectPuppeteerExecutablePath()
})
MAIN_BOSSGEEKGO_UI_RUN_MODE: 'geekAutoStartWithBoss',
PUPPETEER_EXECUTABLE_PATH: await getExpectPuppeteerExecutablePath()
}
subProcessOfPuppeteer = childProcess.spawn(process.argv[0], process.argv.slice(1), {
env: subProcessEnv,