Method: Scruber::AppSearcher#exec_app

Defined in:
lib/scruber/app_searcher.rb

#exec_appObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/scruber/app_searcher.rb', line 9

def exec_app
  original_cwd = Dir.pwd

  loop do
    if exe = find_executable
      exec RUBY, exe, *ARGV
      break # non reachable, hack to be able to stub exec in the test suite
    end

    # If we exhaust the search there is no executable, this could be a
    # call to generate a new application, so restore the original cwd.
    Dir.chdir(original_cwd) && return if Pathname.new(Dir.pwd).root?

    # Otherwise keep moving upwards in search of an executable.
    Dir.chdir("..")
  end
  true
end