Skip to content

Commit

Permalink
🐛 Fixed mixins merge order bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mkarlesky committed Jul 10, 2024
1 parent 674c556 commit 922701f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions bin/mixinator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def validate_env_filepaths(vars)
def assemble_mixins(config:, env:, cmdline:)
assembly = []

# Build list of hashses to facilitate deduplication
# Build list of hashses in precedence order to facilitate deduplication
# Any duplicates at greater indexes are removed
cmdline.each {|mixin| assembly << {'command line' => mixin}}
assembly += env
config.each {|mixin| assembly << {'project configuration' => mixin}}
Expand All @@ -87,8 +88,12 @@ def assemble_mixins(config:, env:, cmdline:)
@path_validator.filepath?( mixin ) ? File.expand_path( mixin ) : mixin
end

# Return the compacted list (in merge order)
return assembly
# Return the compacted list in merge order
# 1. Config
# 2. Environment variable
# 3. Command line
# Later merges take precedence (e.g. command line mixins are last merge)
return assembly.reverse()
end

def merge(builtins:, config:, mixins:)
Expand Down

0 comments on commit 922701f

Please sign in to comment.