Skip to content

Commit 7a75a34

Browse files
committed
Refactor launch_browser to accept a single params object
- launch_browser should accept params variable, don't destructure in body
1 parent f507095 commit 7a75a34

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

‎apps/editor/src/views/prompt/backend/message-handlers/handle-run-browser.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import {
1111
} from '@puppeteer/browsers'
1212
import { t } from '@/i18n'
1313

14-
const launch_browser = (
15-
executable_path: string,
16-
user_data_dir: string,
14+
const launch_browser = (params: {
15+
executable_path: string
16+
user_data_dir: string
1717
extension_path: string
18-
) => {
18+
}) => {
1919
const args = [
20-
`--user-data-dir=${user_data_dir}`,
21-
`--load-extension=${extension_path}`,
20+
`--user-data-dir=${params.user_data_dir}`,
21+
`--load-extension=${params.extension_path}`,
2222
'--disable-infobars',
2323
'--no-first-run'
2424
]
@@ -29,7 +29,7 @@ const launch_browser = (
2929
args.push('--password-store=basic')
3030
}
3131

32-
const child = spawn(executable_path, args, {
32+
const child = spawn(params.executable_path, args, {
3333
detached: true,
3434
stdio: 'ignore'
3535
})
@@ -75,7 +75,7 @@ export const handle_run_browser = async () => {
7575
if (fs.existsSync(cached_path_file)) {
7676
const executable_path = fs.readFileSync(cached_path_file, 'utf-8').trim()
7777
if (fs.existsSync(executable_path)) {
78-
launch_browser(executable_path, user_data_dir, extension_path)
78+
launch_browser({ executable_path, user_data_dir, extension_path })
7979
return
8080
}
8181
}
@@ -131,7 +131,7 @@ export const handle_run_browser = async () => {
131131
}
132132

133133
fs.writeFileSync(cached_path_file, executable_path)
134-
launch_browser(executable_path, user_data_dir, extension_path)
134+
launch_browser({ executable_path, user_data_dir, extension_path })
135135
} catch (error: any) {
136136
if (error.message === 'Download cancelled') {
137137
return

0 commit comments

Comments
 (0)