Fix Installer not supporting plain executables.
This commit is contained in:
parent
05cb6cda08
commit
20ec595cb2
@ -14,16 +14,32 @@ module Hbc
|
|||||||
To complete the installation of Cask #{cask}, you must also
|
To complete the installation of Cask #{cask}, you must also
|
||||||
run the installer at
|
run the installer at
|
||||||
|
|
||||||
'#{path}'
|
'#{cask.staged_path.join(path)}'
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module ScriptInstaller
|
module ScriptInstaller
|
||||||
def install_phase(command: nil, **_)
|
def install_phase(command: nil, **_)
|
||||||
ohai "Running #{self.class.dsl_key} script '#{path.relative_path_from(cask.staged_path)}'"
|
ohai "Running #{self.class.dsl_key} script '#{path}'"
|
||||||
FileUtils.chmod "+x", path unless path.executable?
|
|
||||||
command.run!(path, **args, env: { "PATH" => PATH.new(HOMEBREW_PREFIX/"bin", HOMEBREW_PREFIX/"sbin", ENV["PATH"]) })
|
absolute_path = if path.absolute?
|
||||||
|
path
|
||||||
|
else
|
||||||
|
cask.staged_path.join(path)
|
||||||
|
end
|
||||||
|
|
||||||
|
if absolute_path.exist? && !absolute_path.executable?
|
||||||
|
FileUtils.chmod "+x", absolute_path
|
||||||
|
end
|
||||||
|
|
||||||
|
executable = if absolute_path.exist?
|
||||||
|
absolute_path
|
||||||
|
else
|
||||||
|
path
|
||||||
|
end
|
||||||
|
|
||||||
|
command.run!(executable, **args, env: { "PATH" => PATH.new(HOMEBREW_PREFIX/"bin", HOMEBREW_PREFIX/"sbin", ENV["PATH"]) })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -54,7 +70,7 @@ module Hbc
|
|||||||
super(cask)
|
super(cask)
|
||||||
|
|
||||||
if args.key?(:manual)
|
if args.key?(:manual)
|
||||||
@path = cask.staged_path.join(args[:manual])
|
@path = Pathname(args[:manual])
|
||||||
@args = []
|
@args = []
|
||||||
extend(ManualInstaller)
|
extend(ManualInstaller)
|
||||||
return
|
return
|
||||||
@ -65,17 +81,16 @@ module Hbc
|
|||||||
)
|
)
|
||||||
raise CaskInvalidError.new(cask, "#{self.class.dsl_key} missing executable") if path.nil?
|
raise CaskInvalidError.new(cask, "#{self.class.dsl_key} missing executable") if path.nil?
|
||||||
|
|
||||||
path = Pathname(path)
|
@path = Pathname(path)
|
||||||
@path = path.absolute? ? path : cask.staged_path.join(path)
|
|
||||||
extend(ScriptInstaller)
|
extend(ScriptInstaller)
|
||||||
end
|
end
|
||||||
|
|
||||||
def summarize
|
def summarize
|
||||||
path.relative_path_from(cask.staged_path).to_s
|
path.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_h
|
def to_h
|
||||||
{ path: path.relative_path_from(cask.staged_path).to_s }.tap do |h|
|
{ path: path }.tap do |h|
|
||||||
h[:args] = args unless is_a?(ManualInstaller)
|
h[:args] = args unless is_a?(ManualInstaller)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -520,7 +520,7 @@ describe Hbc::DSL, :cask do
|
|||||||
it "allows installer manual to be specified" do
|
it "allows installer manual to be specified" do
|
||||||
installer = cask.artifacts.first
|
installer = cask.artifacts.first
|
||||||
expect(installer).to be_a(Hbc::Artifact::Installer::ManualInstaller)
|
expect(installer).to be_a(Hbc::Artifact::Installer::ManualInstaller)
|
||||||
expect(installer.path).to eq(cask.staged_path.join("Caffeine.app"))
|
expect(installer.path).to eq(Pathname("Caffeine.app"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user