Skip to content

Commit

Permalink
fix: prefix match is not quite correct.
Browse files Browse the repository at this point in the history
fix #229
  • Loading branch information
aooohan committed Apr 28, 2024
1 parent cf48f4f commit 350e67a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/plugins/create/howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ end

## Optional hook functions

::: warning
You must delete the corresponding `.lua` file if you do not need these hook functions!
:::

### PostInstall

This hook function is called after the `PreInstall` function is executed. It is used to execute additional operations,
Expand Down
4 changes: 4 additions & 0 deletions docs/zh-hans/plugins/create/howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ end

## 可选钩子函数

::: warning
如果不需要这些钩子函数,请**删除对应的`.lua`文件**!
:::

### PostInstall

拓展点,在`PreInstall`执行之后调用,用于执行额外的操作, 如编译源码等。根据需要实现。
Expand Down
8 changes: 6 additions & 2 deletions internal/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,10 @@ func (b *Sdk) PreUse(version Version, scope UseScope) (Version, error) {
installedVersions = append(installedVersions, string(sdk.Main.Version))
}
sort.Sort(installedVersions)
prefix := string(version)
version := string(version)
prefix := version + "."
for _, v := range installedVersions {
if prefix == v {
if version == v {
newVersion = Version(v)
break
}
Expand All @@ -266,6 +267,9 @@ func (b *Sdk) PreUse(version Version, scope UseScope) (Version, error) {
}
}
}
if newVersion == "" {
return version, nil
}

return newVersion, nil
}
Expand Down

0 comments on commit 350e67a

Please sign in to comment.