Only show “sudo” message when it is actually needed.

This commit is contained in:
Markus Reiter 2017-02-17 04:01:50 +01:00
parent f4965685ba
commit 89f4d153a2

View File

@ -21,9 +21,10 @@ module Hbc
return if Hbc.caskroom.exist?
ohai "Creating Caskroom at #{Hbc.caskroom}"
ohai "We'll set permissions properly so we won't need sudo in the future"
sudo = !Hbc.caskroom.parent.writable?
ohai "We'll set permissions properly so we won't need sudo in the future" if sudo
SystemCommand.run("/bin/mkdir", args: ["-p", Hbc.caskroom], sudo: sudo)
SystemCommand.run("/bin/chmod", args: ["g+rwx", Hbc.caskroom], sudo: sudo)
SystemCommand.run("/usr/sbin/chown", args: [Utils.current_user, Hbc.caskroom], sudo: sudo)