Method: BaseChip.find_root

Defined in:
lib/base_chip.rb

.find_root(dir = nil, passive = false) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/base_chip.rb', line 67

def self.find_root(dir = nil, passive=false)
  dir ||= @work_dir ||= Dir.pwd
  @dirs_to_top = []
  loop do
    @dirs_to_top << dir
    break if File.exist? dir + '/base_chip/settings.rb'

    if dir == '/'
      return nil if passive
      fault "Couldn't find file 'base_chip/settings.rb' in any directory above #{Dir.pwd}.\n" +
            "'base_chip/settings.rb' is expected to reside at the top of the checked " +
            "out project, and is generated using the command 'base_chip init'."
    end
    dir = File.expand_path(dir + '/../')
  end
  $project_root = @root = dir
end