Merge pull request #3715 from commitay/moved

cask move_back: copy / delete
This commit is contained in:
commitay 2018-02-21 07:47:43 +10:00 committed by GitHub
commit bab4bb68ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -62,14 +62,16 @@ module Hbc
raise CaskError, "It seems the #{self.class.english_name} source '#{target}' is not there."
end
ohai "Moving #{self.class.english_name} '#{target.basename}' back to '#{source}'."
ohai "Backing #{self.class.english_name} '#{target.basename}' up to '#{source}'."
source.dirname.mkpath
if target.parent.writable?
FileUtils.move(target, source)
FileUtils.cp_r(target, source)
else
command.run("/bin/mv", args: [target, source], sudo: true)
command.run("/bin/cp", args: ["-r", target, source], sudo: true)
end
delete(target, force: force, command: command, **options)
end
def delete(target, force: false, command: nil, **_)

View File

@ -13,7 +13,8 @@ describe Hbc::CLI::Reinstall, :cask do
Already downloaded: .*local-caffeine--1.2.3.zip
==> Verifying checksum for Cask local-caffeine
==> Uninstalling Cask local-caffeine
==> Moving App 'Caffeine.app' back to '.*Caffeine.app'.
==> Backing App 'Caffeine.app' up to '.*Caffeine.app'.
==> Removing App '.*Caffeine.app'.
==> Purging files for version 1.2.3 of Cask local-caffeine
==> Installing Cask local-caffeine
==> Moving App 'Caffeine.app' to '.*Caffeine.app'.

View File

@ -12,7 +12,8 @@ describe Hbc::CLI::Uninstall, :cask do
output = Regexp.new <<~EOS
==> Uninstalling Cask local-caffeine
==> Moving App 'Caffeine.app' back to '.*Caffeine.app'.
==> Backing App 'Caffeine.app' up to '.*Caffeine.app'.
==> Removing App '.*Caffeine.app'.
==> Purging files for version 1.2.3 of Cask local-caffeine
EOS