-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
index.ts
115 lines (104 loc) · 3.35 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { findApp, FindAppParams } from './util'
import type { Browser, DetectedBrowser } from '@packages/types'
import * as linuxHelper from '../linux'
import Debug from 'debug'
import { get } from 'lodash'
const debugVerbose = Debug('cypress-verbose:launcher:darwin')
type Detectors = {
[name: string]: {
[channel: string]: FindAppParams
}
}
export const browsers: Detectors = {
chrome: {
stable: {
appName: 'Google Chrome.app',
executable: 'Contents/MacOS/Google Chrome',
appId: 'com.google.Chrome',
versionProperty: 'KSVersion',
},
beta: {
appName: 'Google Chrome Beta.app',
executable: 'Contents/MacOS/Google Chrome Beta',
appId: 'com.google.Chrome.beta',
versionProperty: 'KSVersion',
},
canary: {
appName: 'Google Chrome Canary.app',
executable: 'Contents/MacOS/Google Chrome Canary',
appId: 'com.google.Chrome.canary',
versionProperty: 'KSVersion',
},
},
chromium: {
stable: {
appName: 'Chromium.app',
executable: 'Contents/MacOS/Chromium',
appId: 'org.chromium.Chromium',
versionProperty: 'CFBundleShortVersionString',
},
},
firefox: {
stable: {
appName: 'Firefox.app',
executable: 'Contents/MacOS/firefox',
appId: 'org.mozilla.firefox',
versionProperty: 'CFBundleShortVersionString',
},
dev: {
appName: 'Firefox Developer Edition.app',
executable: 'Contents/MacOS/firefox',
appId: 'org.mozilla.firefoxdeveloperedition',
versionProperty: 'CFBundleShortVersionString',
},
nightly: {
appName: 'Firefox Nightly.app',
executable: 'Contents/MacOS/firefox',
appId: 'org.mozilla.nightly',
versionProperty: 'CFBundleShortVersionString',
},
},
edge: {
stable: {
appName: 'Microsoft Edge.app',
executable: 'Contents/MacOS/Microsoft Edge',
appId: 'com.microsoft.Edge',
versionProperty: 'CFBundleShortVersionString',
},
canary: {
appName: 'Microsoft Edge Canary.app',
executable: 'Contents/MacOS/Microsoft Edge Canary',
appId: 'com.microsoft.Edge.Canary',
versionProperty: 'CFBundleShortVersionString',
},
beta: {
appName: 'Microsoft Edge Beta.app',
executable: 'Contents/MacOS/Microsoft Edge Beta',
appId: 'com.microsoft.Edge.Beta',
versionProperty: 'CFBundleShortVersionString',
},
dev: {
appName: 'Microsoft Edge Dev.app',
executable: 'Contents/MacOS/Microsoft Edge Dev',
appId: 'com.microsoft.Edge.Dev',
versionProperty: 'CFBundleShortVersionString',
},
},
}
export const getVersionString = linuxHelper.getVersionString
export const getVersionNumber = linuxHelper.getVersionNumber
export const getPathData = linuxHelper.getPathData
export function detect (browser: Browser): Promise<DetectedBrowser> {
let findAppParams = get(browsers, [browser.name, browser.channel])
if (!findAppParams) {
// ok, maybe it is custom alias?
debugVerbose('could not find %s in findApp map, falling back to linux detection method', browser.name)
return linuxHelper.detect(browser)
}
return findApp(findAppParams)
.then((val) => ({ name: browser.name, ...val }))
.catch((err) => {
debugVerbose('could not detect %s using findApp %o, falling back to linux detection method', browser.name, err)
return linuxHelper.detect(browser)
})
}