-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfinder.v
70 lines (64 loc) · 1.21 KB
/
finder.v
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
module cdv
@[params]
struct Paths {
macos_paths []string
win_paths []string
linux_paths []string
other_paths []string
}
fn (p Paths) get_paths() []string {
$if macos {
return p.macos_paths
} $else $if linux {
return p.linux_paths
} $else $if windows {
return p.win_paths
}
if p.other_paths.len == 0 {
return p.linux_paths
}
return p.other_paths
}
pub fn find_path_os(data Paths) !string {
mut path := ''
paths := data.get_paths()
for p in paths {
path = find_executable(p)
if path != '' {
break
}
}
if path == '' {
return error('cannot find chrome path')
}
return path
}
pub fn find_chrome() !string {
return find_path_os(
macos_paths: [
'Google Chrome',
'Chromium',
]
win_paths: ['chrome.exe', 'chromium.exe']
linux_paths: [
'google-chrome',
'google-chrome-stable',
'chromium-browser',
'chromium',
]
)
}
pub fn find_edge() !string {
return find_path_os(
macos_paths: ['Microsoft Edge']
win_paths: ['msedge.exe', 'MicrosoftEdge.exe']
linux_paths: ['microsoft-edge', 'microsoft-edge-stable']
)
}
pub fn find_firefox() !string {
return find_path_os(
macos_paths: ['firefox', 'Firefox']
win_paths: ['firefox.exe']
linux_paths: ['firefox']
)
}