Skip to content

Commit ef3e8cb

Browse files
committed
Implement file patching in Ruby for cross platform compatibility
1 parent aeff6dd commit ef3e8cb

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

Rakefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'fileutils'
2+
13
task :clean do
24
sh('rm -rf _site')
35
end
@@ -14,7 +16,13 @@ task :dependencies do
1416

1517
# Fix pathutil on Ruby 3; works around https://github.com/envygeeks/pathutil/pull/5
1618
# as suggested by https://stackoverflow.com/a/73909894/67873
17-
sh('sed -i.bak "s/, kwd/, **kwd/" $(bundle exec gem which pathutil)')
19+
pathutil_path = `bundle exec gem which pathutil`.chomp()
20+
content = File.read(pathutil_path).gsub(', kwd', ', **kwd')
21+
backup_path = '#{pathutil_path}.bak'
22+
if File.exist?(backup_path) then
23+
FileUtil.mv(pathutil_path, backup_path)
24+
end
25+
File.write(pathutil_path, content)
1826
end
1927

2028
task :spelling_dependencies do

0 commit comments

Comments
 (0)