diff options
author | KC Braunschweig <kcbraunschweig@gmail.com> | 2011-11-23 13:50:34 -0800 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2012-06-21 11:46:20 -0700 |
commit | 2135a1ccdfb32939453793e81bc6fb1a10297383 (patch) | |
tree | 60421ad88bea96b317496bfa60ff1586b920dc5c | |
parent | 0437552664befece50350caddea784e16e572a48 (diff) | |
download | chef-2135a1ccdfb32939453793e81bc6fb1a10297383.tar.gz |
Refactored flow, functionally identical.
-rw-r--r-- | chef/lib/chef/knife/exec.rb | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/chef/lib/chef/knife/exec.rb b/chef/lib/chef/knife/exec.rb index 597be60c27..2d0c04bd01 100644 --- a/chef/lib/chef/knife/exec.rb +++ b/chef/lib/chef/knife/exec.rb @@ -58,26 +58,25 @@ 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) + # Failing that, try searching the script path. If we can't find # anything, fail gracefully. + Chef::Log.debug("Searching script_path: #{config[:script_path].inspect}") - script = File.expand_path(x) - unless File.exists?(script) - Chef::Log.debug("Searching script_path: #{config[:script_path].inspect}") - config[:script_path].each do |path| - path = File.expand_path(path) - test = File.join(path, x) - Chef::Log.debug("Testing: #{test}") - if File.exists?(test) - script = test - Chef::Log.debug("Found: #{test}") - return script - end + config[:script_path].each do |path| + path = File.expand_path(path) + test = File.join(path, x) + Chef::Log.debug("Testing: #{test}") + if File.exists?(test) + script = test + Chef::Log.debug("Found: #{test}") + return script end - ui.error("\"#{x}\" not found in current directory or script_path, giving up.") - exit(1) end - return script + ui.error("\"#{x}\" not found in current directory or script_path, giving up.") + exit(1) end end |