Don’t reorder “basic” artifacts.

This commit is contained in:
Markus Reiter 2017-10-04 17:46:29 +02:00
parent 51a0de6368
commit 02362259a5
2 changed files with 27 additions and 53 deletions

View File

@ -25,39 +25,5 @@ require "hbc/artifact/zap"
module Hbc module Hbc
module Artifact module Artifact
# NOTE: Order is important here!
#
# The `uninstall` stanza should be run first, as it may
# depend on other artifacts still being installed.
#
# We want to extract nested containers before we
# handle any other artifacts.
#
CLASSES = [
PreflightBlock,
Uninstall,
NestedContainer,
Installer,
App,
Suite,
Artifact, # generic 'artifact' stanza
Colorpicker,
Pkg,
Prefpane,
Qlplugin,
Dictionary,
Font,
Service,
StageOnly,
Binary,
InputMethod,
InternetPlugin,
AudioUnitPlugin,
VstPlugin,
Vst3Plugin,
ScreenSaver,
PostflightBlock,
Zap,
].freeze
end end
end end

View File

@ -21,34 +21,42 @@ module Hbc
end end
def <=>(other) def <=>(other)
return unless other.class < AbstractArtifact
return 0 if self.class == other.class
@@sort_order ||= [ # rubocop:disable Style/ClassVars @@sort_order ||= [ # rubocop:disable Style/ClassVars
PreflightBlock, PreflightBlock,
# The `uninstall` stanza should be run first, as it may
# depend on other artifacts still being installed.
Uninstall, Uninstall,
# We want to extract nested containers before we
# handle any other artifacts.
NestedContainer, NestedContainer,
Installer, Installer,
[
App, App,
Suite, Suite,
Artifact, # generic 'artifact' stanza Artifact,
Colorpicker, Colorpicker,
Pkg,
Prefpane, Prefpane,
Qlplugin, Qlplugin,
Dictionary, Dictionary,
Font, Font,
Service, Service,
StageOnly,
Binary,
InputMethod, InputMethod,
InternetPlugin, InternetPlugin,
AudioUnitPlugin, AudioUnitPlugin,
VstPlugin, VstPlugin,
Vst3Plugin, Vst3Plugin,
ScreenSaver, ScreenSaver,
],
Binary,
Pkg,
PostflightBlock, PostflightBlock,
Zap, Zap,
] ].each_with_index.flat_map { |classes, i| [*classes].map { |c| [c, i] } }.to_h
(@@sort_order.index(self.class) <=> @@sort_order.index(other.class)).to_i (@@sort_order[self.class] <=> @@sort_order[other.class]).to_i
end end
# TODO: this sort of logic would make more sense in dsl.rb, or a # TODO: this sort of logic would make more sense in dsl.rb, or a