Skip to content

Commit

Permalink
fix: skip applescript when no Chromium browser found (fixes #11205)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Dec 17, 2022
1 parent d0757e2 commit c5e8c8e
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions packages/vite/src/node/server/openBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,19 @@ function startBrowserProcess(browser: string | undefined, url: string) {
preferredOSXBrowser && ps.includes(preferredOSXBrowser)
? preferredOSXBrowser
: supportedChromiumBrowsers.find((b) => ps.includes(b))
// Try our best to reuse existing tab with AppleScript
execSync(
`osascript openChrome.applescript "${encodeURI(
url,
)}" "${openedBrowser}"`,
{
cwd: join(VITE_PACKAGE_DIR, 'bin'),
stdio: 'ignore',
},
)
return true
if (openedBrowser) {
// Try our best to reuse existing tab with AppleScript
execSync(
`osascript openChrome.applescript "${encodeURI(
url,
)}" "${openedBrowser}"`,
{
cwd: join(VITE_PACKAGE_DIR, 'bin'),
stdio: 'ignore',
},
)
return true
}
} catch (err) {
// Ignore errors
}
Expand Down

0 comments on commit c5e8c8e

Please sign in to comment.