Skip to content

Commit

Permalink
sort mise package names when generating paths
Browse files Browse the repository at this point in the history
  • Loading branch information
coffee-cup committed Feb 4, 2025
1 parent 3085996 commit 0cbc46d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
6 changes: 3 additions & 3 deletions core/generate/__snapshots__/context_test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@
"customName": "install mise packages: go, node, python"
},
{
"path": "/mise/installs/node/20.18.2/bin"
"path": "/mise/installs/go/1.23.5/bin"
},
{
"path": "/mise/installs/python/3.13.1/bin"
"path": "/mise/installs/node/20.18.2/bin"
},
{
"path": "/mise/installs/go/1.23.5/bin"
"path": "/mise/installs/python/3.13.1/bin"
}
],
"dependsOn": [
Expand Down
15 changes: 12 additions & 3 deletions core/generate/mise_step_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,16 @@ func (b *MiseStepBuilder) Build(options *BuildStepOptions) (*plan.Step, error) {

// Packages installed have binaries available at /mise/installs/{package}/{version}/bin
// We need to add these to the PATH
for _, pkg := range b.MisePackages {
resolved, ok := options.ResolvedPackages[pkg.Name]
for _, pkg := range b.sortedPackageNames() {
resolved, ok := options.ResolvedPackages[pkg]
if !ok || resolved.ResolvedVersion == nil {
continue
}

version := *resolved.ResolvedVersion

step.AddCommands([]plan.Command{
plan.NewPathCommand("/mise/installs/" + pkg.Name + "/" + version + "/bin"),
plan.NewPathCommand("/mise/installs/" + pkg + "/" + version + "/bin"),
})
}

Expand Down Expand Up @@ -184,3 +184,12 @@ func (b *MiseStepBuilder) GetSupportingMiseConfigFiles(path string) []string {

return files
}

func (b *MiseStepBuilder) sortedPackageNames() []string {
packages := make([]string, 0, len(b.MisePackages))
for _, pkg := range b.MisePackages {
packages = append(packages, pkg.Name)
}
sort.Strings(packages)
return packages
}

0 comments on commit 0cbc46d

Please sign in to comment.