tryGetNewerRange.js 361 B

123456789101112
  1. const { semver } = require('@vue/cli-shared-utils')
  2. const leadRE = /^(~|\^|>=?)/
  3. const rangeToVersion = r => r.replace(leadRE, '').replace(/x/g, '0')
  4. module.exports = function tryGetNewerRange (r1, r2) {
  5. const v1 = rangeToVersion(r1)
  6. const v2 = rangeToVersion(r2)
  7. if (semver.valid(v1) && semver.valid(v2)) {
  8. return semver.gt(v1, v2) ? r1 : r2
  9. }
  10. }