diff options
author | Kenji Okimoto <okimoto@clear-code.com> | 2018-03-05 13:07:06 +0900 |
---|---|---|
committer | Kenji Okimoto <okimoto@clear-code.com> | 2018-04-23 09:21:08 +0900 |
commit | 0ac78cf19badcefd4883383d9bf340ae78442d4a (patch) | |
tree | 788bb6670e2555e235e5d0a9dd7c49ad65af67b3 | |
parent | 1e92ea9fbf8a2e42fa81b1fe49027b8cf32d5ca0 (diff) | |
download | bundler-0ac78cf19badcefd4883383d9bf340ae78442d4a.tar.gz |
Scan files array only once
In normal case, all elements in `files` are writable.
So all elements in `files` are scanned.
-rw-r--r-- | lib/bundler.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index 9a9129e07b..0b6f70d9df 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -366,9 +366,9 @@ EOF # if any directory is not writable, we need sudo files = [path, bin_dir] | Dir[bundle_path.join("build_info/*").to_s] | Dir[bundle_path.join("*").to_s] - sudo_needed = files.any? {|f| !File.writable?(f) } + unwritable_files = files.reject {|f| File.writable?(f) } + sudo_needed = !unwritable_files.empty? if sudo_needed - unwritable_files = files.reject {|f| File.writable?(f) } Bundler.ui.warn "Following files may not be writable, so sudo is needed: #{unwritable_files.map(&:to_s).join(",")}" end end |