DEV: Fix methods removed in Ruby 3.2 (#15459)

* File.exists? is deprecated and removed in Ruby 3.2 in favor of
File.exist?
* Dir.exists? is deprecated and removed in Ruby 3.2 in favor of
Dir.exist?
This commit is contained in:
Peter Zhu
2022-01-05 12:45:08 -05:00
committed by GitHub
parent 692ba188bf
commit c5fd8c42db
75 changed files with 140 additions and 140 deletions

View File

@ -424,7 +424,7 @@ class Plugin::Instance
end
def delete_extra_automatic_assets(good_paths)
return unless Dir.exists? auto_generated_path
return unless Dir.exist? auto_generated_path
filenames = good_paths.map { |f| File.basename(f) }
# nuke old files
@ -701,7 +701,7 @@ class Plugin::Instance
end
public_data = File.dirname(path) + "/public"
if Dir.exists?(public_data)
if Dir.exist?(public_data)
target = Rails.root.to_s + "/public/plugins/"
Discourse::Utils.execute_command('mkdir', '-p', target)
@ -839,7 +839,7 @@ class Plugin::Instance
end
def js_asset_exists?
File.exists?(js_file_path)
File.exist?(js_file_path)
end
# Receives an array with two elements:
@ -1085,7 +1085,7 @@ class Plugin::Instance
end
def write_asset(path, contents)
unless File.exists?(path)
unless File.exist?(path)
ensure_directory(path)
File.open(path, "w") { |f| f.write(contents) }
end