Skip to content

Commit 03df912

Browse files
authored
Increase Rakefile compatibility (#1155)
* made Rakefile compatible with Powershell * Cleaned up changes
1 parent 92dd317 commit 03df912

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

Rakefile

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ end
55

66
desc "Build docs using docker"
77
task :build do
8-
exec "#{run_cmd} make html"
8+
cmd = "#{run_cmd} make html"
9+
puts cmd
10+
exec cmd
911
end
1012

1113
desc "Spellcheck"
@@ -15,7 +17,11 @@ end
1517

1618
desc "Open built documentation in browser"
1719
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
1925
end
2026

2127
def user_group
@@ -28,20 +34,28 @@ def image
2834
end
2935

3036
def docker?
31-
`which docker 2>/dev/null 2>&1`
32-
$?.success?
37+
exists? 'docker'
3338
end
3439

3540
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`
3746
$?.success?
3847
end
3948

49+
def windows?
50+
Gem.win_platform?
51+
end
52+
4053
def run_cmd
4154
if podman?
4255
"podman run --rm -it -v #{__dir__}:/doc #{image}"
4356
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}"
4559
else
4660
raise StandardError, "Cannot find any suitable container runtime to build. Need 'podman' or 'docker' installed."
4761
end

0 commit comments

Comments
 (0)