File tree Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change 5
5
6
6
desc "Build docs using docker"
7
7
task :build do
8
- exec "#{ run_cmd } make html"
8
+ cmd = "#{ run_cmd } make html"
9
+ puts cmd
10
+ exec cmd
9
11
end
10
12
11
13
desc "Spellcheck"
15
17
16
18
desc "Open built documentation in browser"
17
19
task :open do
18
- exec '(command -v xdg-open >/dev/null 2>&1 && xdg-open build/html/index.html) || open build/html/index.html'
20
+ if windows?
21
+ system 'start .\build\html\index.html'
22
+ else
23
+ exec '(command -v xdg-open >/dev/null 2>&1 && xdg-open build/html/index.html) || open build/html/index.html'
24
+ end
19
25
end
20
26
21
27
def user_group
@@ -28,20 +34,28 @@ def image
28
34
end
29
35
30
36
def docker?
31
- `which docker 2>/dev/null 2>&1`
32
- $?. success?
37
+ exists? 'docker'
33
38
end
34
39
35
40
def podman?
36
- `which podman 2>/dev/null 2>&1`
41
+ exists? 'podman'
42
+ end
43
+
44
+ def exists? ( program )
45
+ `#{ program } -v 2>/dev/null 2>&1`
37
46
$?. success?
38
47
end
39
48
49
+ def windows?
50
+ Gem . win_platform?
51
+ end
52
+
40
53
def run_cmd
41
54
if podman?
42
55
"podman run --rm -it -v #{ __dir__ } :/doc #{ image } "
43
56
elsif docker?
44
- "docker run --rm -it -v '#{ __dir__ } :/doc' -u '#{ user_group } ' #{ image } "
57
+ user_section = windows? ? nil : "-u '#{ user_group } '"
58
+ "docker run --rm -it -v \" #{ __dir__ } :/doc\" #{ user_section } #{ image } "
45
59
else
46
60
raise StandardError , "Cannot find any suitable container runtime to build. Need 'podman' or 'docker' installed."
47
61
end
You can’t perform that action at this time.
0 commit comments