Permalink
Browse files

Memoize Bundler#requires_sudo? (thanks @tmm1)

  • Loading branch information...
indirect committed Nov 12, 2010
1 parent 3e52bd6 commit 47e08d4d04e90b2324cbebf08e7399660142180c
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/bundler.rb
View
@@ -191,11 +191,14 @@ def default_lockfile
end
def requires_sudo?
+ return @requires_sudo if @checked_for_sudo
+
path = bundle_path
path = path.parent until path.exist?
- sudo_present = !`which sudo 2>#{NULL}`.empty?
+ sudo_present = !(`which sudo 2>#{NULL}` rescue '').empty?
- settings.allow_sudo? && !File.writable?(path) && sudo_present
+ @checked_for_sudo = true
+ @requires_sudo = settings.allow_sudo? && !File.writable?(path) && sudo_present
end
def mkdir_p(path)

0 comments on commit 47e08d4

Please sign in to comment.