diff options
author | Xavier Noria <fxn@hashref.com> | 2013-04-10 17:41:32 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2013-04-10 17:42:00 +0200 |
commit | 40410681255a430c4b45cb97f00ea4b1eaa1b862 (patch) | |
tree | 3de43f757ed08fb18c16d4da10086eaa8b7481ec /railties | |
parent | 1c67ecca05f370faeb6adce44d0d98631a9541d4 (diff) | |
download | rails-40410681255a430c4b45cb97f00ea4b1eaa1b862.tar.gz rails-40410681255a430c4b45cb97f00ea4b1eaa1b862.tar.bz2 rails-40410681255a430c4b45cb97f00ea4b1eaa1b862.zip |
code review of 22e5ab3
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/app_rails_loader.rb | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/railties/lib/rails/app_rails_loader.rb b/railties/lib/rails/app_rails_loader.rb index ef6fcd81b4..aae628290d 100644 --- a/railties/lib/rails/app_rails_loader.rb +++ b/railties/lib/rails/app_rails_loader.rb @@ -6,15 +6,15 @@ module Rails 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 @@ generate it and add it to source control: def self.find_executable EXECUTABLES.find { |exe| File.exists?(exe) } end - end end |