Skip to content

Commit

Permalink
adding multiple possible binary names for linux
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig committed Jan 24, 2019
1 parent e2705e9 commit 31d6e9e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/launcher/lib/browsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const browsers: Browser[] = [
displayName: 'Chromium',
versionRegex: /Chromium (\S+)/,
profile: true,
binary: 'chromium-browser'
binary: ['chromium-browser', 'chromium']
},
{
name: 'canary',
Expand Down
18 changes: 16 additions & 2 deletions packages/launcher/lib/detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -81,8 +81,22 @@ function detectBrowsers(goalBrowsers?: Browser[]): Bluebird<Browser[]> {
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<Browser[]>
}

Expand Down
8 changes: 4 additions & 4 deletions packages/launcher/lib/types.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 31d6e9e

Please sign in to comment.