Method: Bake::Context.bakefile_path
- Defined in:
- lib/bake/context.rb
.bakefile_path(path, bakefile: BAKEFILE) ⇒ Object
Search upwards from the specified path for a BAKEFILE. If path points to a file, assume it’s a bake.rb file. Otherwise, recursively search up the directory tree starting from path to find the specified bakefile.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bake/context.rb', line 19 def self.bakefile_path(path, bakefile: BAKEFILE) if File.file?(path) return path end current = path while current bakefile_path = File.join(current, BAKEFILE) if File.exist?(bakefile_path) return bakefile_path end parent = File.dirname(current) if current == parent break else current = parent end end return nil end |