Skip to content

Commit

Permalink
book: simplify file writing
Browse files Browse the repository at this point in the history
The `File.write(path, content)` form is quite a bit more readable than
the long form.

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Nov 17, 2024
1 parent 3ce6878 commit 17c47dd
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions script/book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,10 @@ def save
end

front_matter = { "redirect_to" => "book/#{@language_code}/v#{@edition}" }
File.open(self.absolute_path("../_index.html"), 'w') do |file|
file.write(self.wrap_front_matter(front_matter))
end
File.write(self.absolute_path("../_index.html"), self.wrap_front_matter(front_matter))

if @language_code == "en"
File.open(self.absolute_path("../../_index.html"), 'w') do |file|
file.write(self.wrap_front_matter(front_matter))
end
File.write(self.absolute_path("../../_index.html"), self.wrap_front_matter(front_matter))
end

FileUtils.mkdir_p(self.absolute_path("ch00"))
Expand Down

0 comments on commit 17c47dd

Please sign in to comment.