Skip to content

版本比较存在问题 #2

@linkscope

Description

@linkscope

源码中的版本比较是

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的场景,导致版本比较失败。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions