Method: Fire::Session#root

Defined in:
lib/fire/session.rb

#rootString (private)

Locate project root. This method ascends up the file system starting as the current working directory looking for ‘ROOT_INDICATORS`. When a match is found, the directory in which it is found is returned as the root. It is also memoized, so repeated calls to this method will not repeat the search.

Returns:

  • (String)

    Returns



232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/fire/session.rb', line 232

def root
  @root ||= (
    r = nil
    d = Dir.pwd
    while d != home && d != '/'
      if ROOT_INDICATORS.any?{ |g| Dir.glob(File.join(d, g), File::FNM_CASEFOLD).first }
        break r = d
      end
      d = File.dirname(d)
    end
    abort "Can't locate project root." unless r
    r
  )
end