add check dependencies logic before automatic start

This commit is contained in:
bossgeekgo
2024-02-17 21:39:35 +08:00
parent 4a86b57f57
commit 5ede58169d
2 changed files with 34 additions and 13 deletions
+11 -6
View File
@@ -101,13 +101,8 @@ export function createMainWindow(): void {
env: subProcessEnv,
stdio: [null, null, null, 'pipe']
})
subProcessOfPuppeteer.once('exit', () => {
mainWindow.webContents.send('geek-auto-start-chat-with-boss-stopped')
subProcessOfPuppeteer = null
})
console.log(subProcessOfPuppeteer)
return new Promise((resolve) => {
return new Promise((resolve, reject) => {
subProcessOfPuppeteer!.stdio[3]!.pipe(JSONStream.parse()).on('data', (raw) => {
const data = raw
switch (data.type) {
@@ -120,6 +115,16 @@ export function createMainWindow(): void {
}
}
})
subProcessOfPuppeteer!.once('exit', (exitCode) => {
subProcessOfPuppeteer = null
if (exitCode === 1) {
// means cannot find downloaded puppeteer
reject('NEED_TO_CHECK_RUNTIME_DEPENDENCIES')
} else {
mainWindow.webContents.send('geek-auto-start-chat-with-boss-stopped')
}
})
})
// TODO:
})