Fix browser launch on android
This commit is contained in:
@@ -21,6 +21,7 @@ browserLaunch:
|
|||||||
# Open the browser automatically on server startup.
|
# Open the browser automatically on server startup.
|
||||||
enabled: true
|
enabled: true
|
||||||
# Browser to use for opening the URL.
|
# Browser to use for opening the URL.
|
||||||
|
# NOT SUPPORTED ON ANDROID DEVICES.
|
||||||
# - Use "default" to use the system default browser
|
# - Use "default" to use the system default browser
|
||||||
# - Use "firefox", "chrome", "edge"
|
# - Use "firefox", "chrome", "edge"
|
||||||
browser: 'default'
|
browser: 'default'
|
||||||
|
|||||||
+14
-6
@@ -329,18 +329,26 @@ async function postSetupTasks(result) {
|
|||||||
|
|
||||||
if (cliArgs.browserLaunchEnabled) {
|
if (cliArgs.browserLaunchEnabled) {
|
||||||
try {
|
try {
|
||||||
const validBrowsers = {
|
function getBrowsers() {
|
||||||
'firefox': apps.firefox,
|
const isAndroid = process.platform === 'android';
|
||||||
'chrome': apps.chrome,
|
if (isAndroid) {
|
||||||
'edge': apps.edge,
|
return {};
|
||||||
};
|
}
|
||||||
|
return {
|
||||||
|
'firefox': apps.firefox,
|
||||||
|
'chrome': apps.chrome,
|
||||||
|
'edge': apps.edge,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const validBrowsers = getBrowsers();
|
||||||
const appName = validBrowsers[browserLaunchApp.trim().toLowerCase()];
|
const appName = validBrowsers[browserLaunchApp.trim().toLowerCase()];
|
||||||
const openOptions = appName ? { app: { name: appName } } : {};
|
const openOptions = appName ? { app: { name: appName } } : {};
|
||||||
|
|
||||||
console.log(`Launching in a browser: ${browserLaunchApp}...`);
|
console.log(`Launching in a browser: ${browserLaunchApp}...`);
|
||||||
await open(browserLaunchUrl.toString(), openOptions);
|
await open(browserLaunchUrl.toString(), openOptions);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to launch the browser. Open the URL manually.');
|
console.error('Failed to launch the browser. Open the URL manually.', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user