Skip to content

Commit

Permalink
fix: skip applescript when no Chromium browser found (fixes vitejs#11205
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre authored and futurGH committed Feb 26, 2023
1 parent 762c5c7 commit 7a7ffd8
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions packages/vite/src/node/server/openBrowser.ts
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 7a7ffd8

Please sign in to comment.