Skip to content

Commit

Permalink
Make preview task work on things other than macos
Browse files Browse the repository at this point in the history
  • Loading branch information
peteryates committed Apr 18, 2024
1 parent c6ea4d9 commit 11b5883
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ inherit_gem:
inherit_mode:
merge:
- Exclude

Style/EmptyCaseCondition:
Enabled: false
11 changes: 10 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require "mkmf"
require "bundler/gem_tasks"
require "rspec/core/rake_task"

Expand All @@ -13,7 +14,15 @@ task :generate_example do
html = GovukMarkdown.render(markdown)

File.write("example/example.html", ERB.new(File.read("example/example_layout.html.erb")).result(binding))
sh "open example/example.html"

case
when find_executable("xdg-open") # linux
sh("xdg-open example/example.html")
when find_executable("open") # mac
sh("open example/example.html")
else
puts "View the example in example/example.html"
end
end

desc "Print the current version of the gem"
Expand Down

0 comments on commit 11b5883

Please sign in to comment.