Skip to content

Commit

Permalink
Fix bug giving wrong sort-order randomly
Browse files Browse the repository at this point in the history
  • Loading branch information
azimux committed Jan 17, 2024
1 parent 67bd107 commit 6358efe
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/load_dotenv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ def sort_env_files
max_envs = env_files_to_apply.map { |env_file| env_file.envs&.length }.compact.max || 0

env_files_to_apply.sort_by! do |env_file|
envs_length = env_file.envs&.length || 0

index = max_envs - envs_length + 1

env_file.is_local ? index : index * (envs_length + 2)
envs = env_file.envs || []
envs_length = envs.length

[
env_file.is_local ? 0 : 1,
max_envs - envs_length + 1,
envs.sort
]
end
end

Expand Down

0 comments on commit 6358efe

Please sign in to comment.