forked from gabrielbull/react-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (26 loc) · 665 Bytes
/
index.js
File metadata and controls
29 lines (26 loc) · 665 Bytes
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
export function os() {
// explicitly set these to avoid issues
const window = window || null;
const navigator = navigator || null;
const process = process || (window && window.process) || null;
// via node
if (process && process.platform) {
if (process.platform === 'darwin') {
return 'osx';
}
if (process.platform.includes('win')) {
return 'windows';
}
}
// via user agent
if (navigator && navigator.userAgent) {
if (navigator.userAgent.includes('Macintosh')) {
return 'osx';
}
if (navigator.userAgent.includes('Windows')) {
return 'windows';
}
}
// default to osx
return 'osx';
}