Skip to content

Commit

Permalink
Replace all occurrences of File.exists? with File.exist?
Browse files Browse the repository at this point in the history
Summary:

Every time I go to use `File.exist?` I think to myself, "Which is it, `File.exists?` or `File.exist?`," and I go do a big grep search to discover that it's.... both?

Well, according to the [ruby docs](https://ruby-doc.org/core-2.2.0/File.html#exist-3F-method), `File.exists?` is deprecated.

So as a gift to my future self who will be doing an big grep in the future, this diff will replace all instances of `File.exists?` with `File.exist?` in cpe_* cookbooks.

Also, same thing for `Dir.exists?` => `Dir.exist?`

Reviewed By: gbatye, steelcowboy

Differential Revision: D21507238

fbshipit-source-id: 307533d148963088a84c0f5089ad708ba57a1239
  • Loading branch information
chilcote authored and facebook-github-bot committed May 12, 2020
1 parent 5d1b850 commit 5e0bce5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions itchef/cookbooks/cpe_flatpak/libraries/flatpak_helpers.rb
Expand Up @@ -28,7 +28,7 @@ def flatpak_remotes_receipt_path
end

def flatpak_remotes_receipt
return [] unless ::File.exists?(flatpak_remotes_receipt_path)
return [] unless ::File.exist?(flatpak_remotes_receipt_path)
Chef::JSONCompat.from_json(::File.read(flatpak_remotes_receipt_path))
rescue StandardError
[]
Expand All @@ -39,7 +39,7 @@ def flatpak_packages_receipt_path
end

def flatpak_packages_receipt
return [] unless ::File.exists?(flatpak_packages_receipt_path)
return [] unless ::File.exist?(flatpak_packages_receipt_path)
Chef::JSONCompat.from_json(::File.read(flatpak_packages_receipt_path))
rescue StandardError
[]
Expand Down
2 changes: 1 addition & 1 deletion itchef/cookbooks/cpe_remote/resources/file.rb
Expand Up @@ -46,7 +46,7 @@

load_current_value do |desired| # ~FC006
path = desired.path
if ::File.exists?(path)
if ::File.exist?(path)
f_stat = ::File.stat(path)
checksum_ondisk = Chef::Digester.checksum_for_file(path)
checksum checksum_ondisk
Expand Down
4 changes: 2 additions & 2 deletions itchef/cookbooks/cpe_remote/resources/zip.rb
Expand Up @@ -44,13 +44,13 @@
extra_loco = extract_location.delete(':')
zip_path = ::File.join(chef_cache, 'remote_zip', extra_loco, zip_name)

if ::File.exists?(zip_path)
if ::File.exist?(zip_path)
checksum_ondisk = Chef::Digester.checksum_for_file(zip_path)
zip_checksum checksum_ondisk
end

extract_path = desired.extract_location
if ::File.exists?(extract_path)
if ::File.exist?(extract_path)
f_stat = ::File.stat(extract_path)
unless platform?('windows')
owner ::Etc.getpwuid(f_stat.uid).name
Expand Down
2 changes: 1 addition & 1 deletion itchef/cookbooks/cpe_symlinks/resources/cpe_symlinks.rb
Expand Up @@ -30,7 +30,7 @@
# Create symlinks on disk
node['cpe_symlinks'].to_h.map.each do |target_dir, symlinks|
symlinks.each do |target, source|
next unless ::File.exists?(source)
next unless ::File.exist?(source)
link ::File.join(target_dir, target) do
to source
end
Expand Down

0 comments on commit 5e0bce5

Please sign in to comment.