Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

版本比较存在问题 #2

Open
linkscope opened this issue Apr 29, 2021 · 0 comments
Open

版本比较存在问题 #2

linkscope opened this issue Apr 29, 2021 · 0 comments

Comments

@linkscope
Copy link

源码中的版本比较是

versions.sort((a, b) => semver.gt(b, a))

这么比较是存在问题的,semver.gt返回的boolean类型的true和false,而sort函数规定的确是数字:
大于0:b置换a
等于0:a与b位置不变
小于0:a置换b
这种比较只会发生b置换a,但却没有a置换b的场景,导致版本比较失败。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant