1
0
mirror of https://github.com/actions/setup-python synced 2024-12-02 21:42:28 +08:00
setup-python/node_modules/semver-compare/index.js

14 lines
372 B
JavaScript
Raw Normal View History

2019-06-27 09:12:00 +08:00
module.exports = function cmp (a, b) {
var pa = a.split('.');
var pb = b.split('.');
for (var i = 0; i < 3; i++) {
var na = Number(pa[i]);
var nb = Number(pb[i]);
if (na > nb) return 1;
if (nb > na) return -1;
if (!isNaN(na) && isNaN(nb)) return 1;
if (isNaN(na) && !isNaN(nb)) return -1;
}
return 0;
};