-
-
Notifications
You must be signed in to change notification settings - Fork 328
/
os.rb
59 lines (49 loc) · 1021 Bytes
/
os.rb
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
# frozen_string_literal: true
module Opal
module OS
module_function
def windows?
/bccwin|cygwin|djgpp|mingw|mswin|wince/.match?(RbConfig::CONFIG['host_os'])
end
def macos?
/darwin|mac os/.match?(RbConfig::CONFIG['host_os'])
end
def shellescape(str)
if windows?
'"' + str.gsub('"', '""') + '"'
else
str.shellescape
end
end
def env_sep
windows? ? ';' : ':'
end
def path_sep
windows? ? '\\' : '/'
end
def cmd_sep
windows? ? ' & ' : ' ; '
end
def dev_null
windows? ? 'NUL' : '/dev/null'
end
def bash_c(*commands)
cmd = if windows?
[
'bundle',
'exec',
'cmd',
'/c',
]
else
[
'bundle',
'exec',
'bash',
'-c',
]
end
cmd << commands.join(cmd_sep)
end
end
end