From 38c66e4a8fd2ac6e7c005c5a823ff4152b22a903 Mon Sep 17 00:00:00 2001 From: toshimaru Date: Sun, 12 Nov 2023 16:31:00 +0900 Subject: [PATCH] Add `remove_existing_files` method --- Rakefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Rakefile b/Rakefile index 6cea33fa55..3aedf2799b 100644 --- a/Rakefile +++ b/Rakefile @@ -77,6 +77,7 @@ end def generate_src(target_version:) copy_sources = Dir.glob('rails/doc/rdoc/*').reject { |path| path.end_with?('panel', 'js', 'created.rid') } target_dir = target_version == default_rails_version ? SOURCE_DIR : "#{SOURCE_DIR}/#{target_version}" + remove_existing_files(target_dir) cp_r copy_sources, target_dir cd target_dir do @@ -92,3 +93,10 @@ def generate_src(target_version:) File.write('navigation.html', content) end end + +EXISTING_DIRS = %w[classes files].freeze +def remove_existing_files(target_dir) + EXISTING_DIRS.each do |dir| + rm_rf "#{target_dir}/#{dir}" + end +end