summaryrefslogtreecommitdiff
path: root/lib/chef/knife
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-08-14 10:15:40 -0700
committerGitHub <noreply@github.com>2020-08-14 10:15:40 -0700
commitc0c8c32e41a4496d3b78acc942f26f667045b3f8 (patch)
treee1ba9028cb89f0fc83fcbecb5ed778ac4ad6f630 /lib/chef/knife
parentb9df6856a1eb4688f013ba0449a362f951ab40e5 (diff)
parent4848c89b7cc5e4a4d4fac7c8bff962f7df69f719 (diff)
downloadchef-c0c8c32e41a4496d3b78acc942f26f667045b3f8.tar.gz
Merge pull request #10284 from chef/exist
Fix File.exist throughout the codebase
Diffstat (limited to 'lib/chef/knife')
-rw-r--r--lib/chef/knife/bootstrap.rb4
-rw-r--r--lib/chef/knife/cookbook_download.rb2
-rw-r--r--lib/chef/knife/cookbook_metadata.rb2
-rw-r--r--lib/chef/knife/core/hashed_command_loader.rb4
-rw-r--r--lib/chef/knife/exec.rb4
5 files changed, 8 insertions, 8 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index e48fd71194..a3f7d3a23c 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -480,7 +480,7 @@ class Chef
template = bootstrap_template
# Use the template directly if it's a path to an actual file
- if File.exists?(template)
+ if File.exist?(template)
Chef::Log.trace("Using the specified bootstrap template: #{File.dirname(template)}")
return template
end
@@ -495,7 +495,7 @@ class Chef
template_file = Array(bootstrap_files).find do |bootstrap_template|
Chef::Log.trace("Looking for bootstrap template in #{File.dirname(bootstrap_template)}")
- File.exists?(bootstrap_template)
+ File.exist?(bootstrap_template)
end
unless template_file
diff --git a/lib/chef/knife/cookbook_download.rb b/lib/chef/knife/cookbook_download.rb
index 6c567684af..a07b519511 100644
--- a/lib/chef/knife/cookbook_download.rb
+++ b/lib/chef/knife/cookbook_download.rb
@@ -73,7 +73,7 @@ class Chef
manifest = cookbook.cookbook_manifest
basedir = File.join(config[:download_directory], "#{@cookbook_name}-#{cookbook.version}")
- if File.exists?(basedir)
+ if File.exist?(basedir)
if config[:force]
Chef::Log.trace("Deleting #{basedir}")
FileUtils.rm_rf(basedir)
diff --git a/lib/chef/knife/cookbook_metadata.rb b/lib/chef/knife/cookbook_metadata.rb
index 3a55e8ba9e..8d8970b1c1 100644
--- a/lib/chef/knife/cookbook_metadata.rb
+++ b/lib/chef/knife/cookbook_metadata.rb
@@ -62,7 +62,7 @@ class Chef
def generate_metadata(cookbook)
Array(config[:cookbook_path]).reverse_each do |path|
file = File.expand_path(File.join(path, cookbook, "metadata.rb"))
- if File.exists?(file)
+ if File.exist?(file)
generate_metadata_from_file(cookbook, file)
else
validate_metadata_json(path, cookbook)
diff --git a/lib/chef/knife/core/hashed_command_loader.rb b/lib/chef/knife/core/hashed_command_loader.rb
index b88cededc0..c1d71f3edf 100644
--- a/lib/chef/knife/core/hashed_command_loader.rb
+++ b/lib/chef/knife/core/hashed_command_loader.rb
@@ -53,7 +53,7 @@ class Chef
paths = manifest[KEY]["plugins_paths"][command]
if paths && paths.is_a?(Array)
# It is only an error if all the paths don't exist
- if paths.all? { |sc| !File.exists?(sc) }
+ if paths.all? { |sc| !File.exist?(sc) }
errors[command] = paths
end
end
@@ -77,7 +77,7 @@ class Chef
false
else
paths.each do |sc|
- if File.exists?(sc)
+ if File.exist?(sc)
Kernel.load sc
else
return false
diff --git a/lib/chef/knife/exec.rb b/lib/chef/knife/exec.rb
index 77b10e6506..9286a91022 100644
--- a/lib/chef/knife/exec.rb
+++ b/lib/chef/knife/exec.rb
@@ -76,7 +76,7 @@ class Chef::Knife::Exec < Chef::Knife
def find_script(x)
# Try to find a script. First try expanding the path given.
script = File.expand_path(x)
- return script if File.exists?(script)
+ return script if File.exist?(script)
# Failing that, try searching the script path. If we can't find
# anything, fail gracefully.
@@ -86,7 +86,7 @@ class Chef::Knife::Exec < Chef::Knife
path = File.expand_path(path)
test = File.join(path, x)
Chef::Log.trace("Testing: #{test}")
- if File.exists?(test)
+ if File.exist?(test)
script = test
Chef::Log.trace("Found: #{test}")
return script