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 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

View File

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