]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
minor fixes to Path.find_file
authorelijah <elijah@riseup.net>
Fri, 31 Oct 2014 06:59:02 +0000 (23:59 -0700)
committerelijah <elijah@riseup.net>
Fri, 31 Oct 2014 06:59:02 +0000 (23:59 -0700)
lib/leap_cli/commands/deploy.rb
lib/leap_cli/path.rb

index 855a820791ff037bf5b642c1380b07bf806cd89a..6589837714df799832721884686cb4fe39bb74c0 100644 (file)
@@ -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
index cd0e169204520bff2877e51a105ceab4855f3346..1f6726ac87f80d784b56022d98a9ae7329e75322 100644 (file)
@@ -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