Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Display unwritable files in each line
Browse files Browse the repository at this point in the history
  • Loading branch information
okkez committed Apr 23, 2018
1 parent 20fc9c7 commit 04e888e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/bundler.rb
Expand Up @@ -369,7 +369,7 @@ def requires_sudo?
unwritable_files = files.reject {|f| File.writable?(f) }
sudo_needed = !unwritable_files.empty?
if sudo_needed
Bundler.ui.warn "Following files may not be writable, so sudo is needed: #{unwritable_files.map(&:to_s).join(",")}"
Bundler.ui.warn "Following files may not be writable, so sudo is needed:\n #{unwritable_files.map(&:to_s).join("\n ")}"
end
end

Expand Down
12 changes: 9 additions & 3 deletions spec/bundler/bundler_spec.rb
Expand Up @@ -320,12 +320,18 @@ def clear_cached_requires_sudo
end
context "unwritable paths" do
before do
FileUtils.touch("tmp/vendor/bundle/unwritable.txt")
FileUtils.chmod(0o400, "tmp/vendor/bundle/unwritable.txt")
FileUtils.touch("tmp/vendor/bundle/unwritable1.txt")
FileUtils.touch("tmp/vendor/bundle/unwritable2.txt")
FileUtils.chmod(0o400, "tmp/vendor/bundle/unwritable1.txt")
FileUtils.chmod(0o400, "tmp/vendor/bundle/unwritable2.txt")
end
it "should return true and display warn message" do
allow(Bundler).to receive(:bundle_path).and_return(Pathname("tmp/vendor/bundle"))
message = "Following files may not be writable, so sudo is needed: tmp/vendor/bundle/unwritable.txt"
message = <<-MESSAGE.chomp
Following files may not be writable, so sudo is needed:
tmp/vendor/bundle/unwritable1.txt
tmp/vendor/bundle/unwritable2.txt
MESSAGE
expect(Bundler.ui).to receive(:warn).with(message)
expect(Bundler.requires_sudo?).to eq(true)
end
Expand Down

0 comments on commit 04e888e

Please sign in to comment.