diff --git a/packages/launcher/lib/browsers.ts b/packages/launcher/lib/browsers.ts index a87254005e72..5eabf446bb48 100644 --- a/packages/launcher/lib/browsers.ts +++ b/packages/launcher/lib/browsers.ts @@ -30,7 +30,7 @@ export const browsers: Browser[] = [ displayName: 'Chromium', versionRegex: /Chromium (\S+)/, profile: true, - binary: 'chromium-browser' + binary: ['chromium-browser', 'chromium'] }, { name: 'canary', diff --git a/packages/launcher/lib/detect.ts b/packages/launcher/lib/detect.ts index 0745135cbb6d..4bbfc2211040 100644 --- a/packages/launcher/lib/detect.ts +++ b/packages/launcher/lib/detect.ts @@ -6,7 +6,7 @@ import { Browser, NotInstalledError } from './types' import { browsers } from './browsers' import * as Bluebird from 'bluebird' import { merge, pick, tap, uniqBy, props } from 'ramda' -import * as _ from 'lodash' +import { extend, compact, flatten } from 'lodash' import * as os from 'os' const setMajorVersion = (obj: Browser) => { @@ -81,8 +81,22 @@ function detectBrowsers(goalBrowsers?: Browser[]): Bluebird { goalBrowsers = browsers } const removeDuplicates = uniqBy(props(['name', 'version'])) + + goalBrowsers = flatten( + goalBrowsers.map((browser: Browser) => { + if (Array.isArray(browser.binary)) { + // if there are multiple valid binaries for a browser, + // try to find each one + return browser.binary.map((binary: string) => + extend({}, browser, { binary }) + ) + } + return [browser] + }) + ) + return Bluebird.mapSeries(goalBrowsers, checkOneBrowser) - .then(_.compact) + .then(compact) .then(removeDuplicates) as Bluebird } diff --git a/packages/launcher/lib/types.ts b/packages/launcher/lib/types.ts index eb51d3448c9c..3b7be797a3de 100644 --- a/packages/launcher/lib/types.ts +++ b/packages/launcher/lib/types.ts @@ -1,17 +1,17 @@ -/** TODO this are typical browser names, not just Mac */ -export type MacBrowserName = 'chrome' | 'chromium' | 'canary' | string +export type BrowserName = 'chrome' | 'chromium' | 'canary' | string export type PlatformName = 'darwin' | 'linux' | 'win32' export type Browser = { /** short browser name */ - name: MacBrowserName + name: BrowserName /** Optional display name */ displayName: string /** RegExp to use to extract version from something like "Google Chrome 58.0.3029.110" */ versionRegex: RegExp profile: boolean - binary: string + /** A single binary name or array of binary names for this browser. Not used on Windows. */ + binary: string | string[] version?: string majorVersion?: string page?: string