aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2014-10-30 23:59:02 -0700
committerelijah <elijah@riseup.net>2014-10-30 23:59:02 -0700
commitb5046d33cedd32fba04b079fe674eab6c7e60532 (patch)
tree59a4347c094c85ba78705ccfdc38ed24b481cc60
parenta24cd0bd22c2ab9a452c1992fa4e9b3691c1c991 (diff)
downloadleap_cli-b5046d33cedd32fba04b079fe674eab6c7e60532.tar.gz
leap_cli-b5046d33cedd32fba04b079fe674eab6c7e60532.tar.bz2
minor fixes to Path.find_file
-rw-r--r--lib/leap_cli/commands/deploy.rb2
-rw-r--r--lib/leap_cli/path.rb26
2 files changed, 21 insertions, 7 deletions
diff --git a/lib/leap_cli/commands/deploy.rb b/lib/leap_cli/commands/deploy.rb
index 855a820..6589837 100644
--- a/lib/leap_cli/commands/deploy.rb
+++ b/lib/leap_cli/commands/deploy.rb
@@ -264,7 +264,7 @@ module LeapCli
end
if prefix
- includes.map! {|path| path.sub(/^#{Regexp.escape(prefix)}/, '')}
+ includes.map! {|path| path.sub(/^#{Regexp.escape(prefix)}\//, '/')}
end
return includes
diff --git a/lib/leap_cli/path.rb b/lib/leap_cli/path.rb
index cd0e169..1f6726a 100644
--- a/lib/leap_cli/path.rb
+++ b/lib/leap_cli/path.rb
@@ -26,15 +26,29 @@ module LeapCli; module Path
end
#
- # tries to find a file somewhere
+ # Tries to find a file somewhere.
+ # Path can be a named path or a relative path.
+ #
+ # relative paths are checked against
+ # provider/<path>
+ # provider/files/<path>
+ # provider_base/<path>
+ # provider_base/files/<path>
+ #
#
def self.find_file(arg)
[Path.provider, Path.provider_base].each do |base|
- file_path = named_path(arg, base)
- return file_path if File.exists?(file_path)
- if arg.is_a? String
- file_path = base + '/files/' + arg
- return file_path if File.exists?(file_path)
+ if arg.is_a?(Symbol) || arg.is_a?(Array)
+ named_path(arg, base).tap {|path|
+ return path if File.exists?(path)
+ }
+ else
+ File.join(base, arg).tap {|path|
+ return path if File.exists?(path)
+ }
+ File.join(base, 'files', arg).tap {|path|
+ return path if File.exists?(path)
+ }
end
end
return nil