aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorYoshimasa Niwa2016-10-15 15:18:51 -0700
committerYoshimasa Niwa2016-10-15 15:19:30 -0700
commit5d606dd0a275446f00f31884ac042572f3a620ad (patch)
treee3fd7525955fd3f3812aae3a4a82c0a92c747730 /Library
parentd51cd15e0c748d1b2a35f6327a131622b6ee48b7 (diff)
downloadbrew-5d606dd0a275446f00f31884ac042572f3a620ad.tar.bz2
Use SystemCommand.run instead of custom wrapper.
There is an existing `SystemCommand.run` that executes command with `sudo`. Use that instead of yet another custom wrapper.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/lib/hbc/caskroom.rb23
1 files changed, 6 insertions, 17 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/caskroom.rb b/Library/Homebrew/cask/lib/hbc/caskroom.rb
index a8af58001..6370fed3f 100644
--- a/Library/Homebrew/cask/lib/hbc/caskroom.rb
+++ b/Library/Homebrew/cask/lib/hbc/caskroom.rb
@@ -13,7 +13,7 @@ module Hbc
FileUtils.mv repo_caskroom, Hbc.caskroom
else
opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom."
- command "/bin/mv", repo_caskroom, Hbc.caskroom.parent, :use_sudo => true
+ SystemCommand.run("/bin/mv", :args => [repo_caskroom, Hbc.caskroom.parent], :sudo => true)
end
end
@@ -22,23 +22,12 @@ module Hbc
ohai "Creating Caskroom at #{Hbc.caskroom}"
ohai "We'll set permissions properly so we won't need sudo in the future"
- use_sudo = !Hbc.caskroom.parent.writable?
+ sudo = !Hbc.caskroom.parent.writable?
- command "/bin/mkdir", "-p", Hbc.caskroom, :use_sudo => use_sudo
- command "/bin/chmod", "g+rwx", Hbc.caskroom, :use_sudo => use_sudo
- command "/usr/sbin/chown", Utils.current_user, Hbc.caskroom, :use_sudo => use_sudo
- command "/usr/bin/chgrp", "admin", Hbc.caskroom, :use_sudo => use_sudo
- end
-
- def command(*args)
- options = args.last.is_a?(Hash) ? args.pop : {}
-
- if options[:use_sudo]
- args.unshift "/usr/bin/sudo"
- end
-
- ohai args.join(" ")
- system *args
+ 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)
+ SystemCommand.run("/usr/bin/chgrp", :args => ["admin", Hbc.caskroom], :sudo => sudo)
end
end
end