Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

code review of 22e5ab3

  • Loading branch information...
commit 40410681255a430c4b45cb97f00ea4b1eaa1b862 1 parent 1c67ecc
@fxn fxn authored
Showing with 7 additions and 8 deletions.
  1. +7 −8 railties/lib/rails/app_rails_loader.rb
View
15 railties/lib/rails/app_rails_loader.rb
@@ -6,15 +6,15 @@ module AppRailsLoader
EXECUTABLES = ['bin/rails', 'script/rails']
def self.exec_app_rails
- cwd = Dir.pwd
- pathname = Pathname.new(Dir.pwd)
+ original_cwd = Dir.pwd
until exe = find_executable
- # Return to working directory if root is hit without finding executable
- Dir.chdir(cwd) and return if pathname.root?
- # Otherwise keep moving upwards in search of executable
- Dir.chdir("..")
- pathname = pathname.parent
+ # 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) and return if Pathname.new(Dir.pwd).root?
+
+ # Otherwise keep moving upwards in search of a executable.
+ Dir.chdir('..')
end
contents = File.read(exe)
@@ -58,6 +58,5 @@ def self.exec_app_rails
def self.find_executable
EXECUTABLES.find { |exe| File.exists?(exe) }
end
-
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.