(comp, options)
| 407 | } |
| 408 | |
| 409 | const replaceXRange = (comp, options) => { |
| 410 | comp = comp.trim() |
| 411 | const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE] |
| 412 | return comp.replace(r, (ret, gtlt, M, m, p, pr) => { |
| 413 | debug('xRange', comp, ret, gtlt, M, m, p, pr) |
| 414 | if (invalidXRangeOrder(M, m, p)) { |
| 415 | return comp |
| 416 | } |
| 417 | |
| 418 | const xM = isX(M) |
| 419 | const xm = xM || isX(m) |
| 420 | const xp = xm || isX(p) |
| 421 | const anyX = xp |
| 422 | |
| 423 | if (gtlt === '=' && anyX) { |
| 424 | gtlt = '' |
| 425 | } |
| 426 | |
| 427 | // if we're including prereleases in the match, then we need |
| 428 | // to fix this to -0, the lowest possible prerelease value |
| 429 | pr = options.includePrerelease ? '-0' : '' |
| 430 | |
| 431 | if (xM) { |
| 432 | if (gtlt === '>' || gtlt === '<') { |
| 433 | // nothing is allowed |
| 434 | ret = '<0.0.0-0' |
| 435 | } else { |
| 436 | // nothing is forbidden |
| 437 | ret = '*' |
| 438 | } |
| 439 | } else if (gtlt && anyX) { |
| 440 | // we know patch is an x, because we have any x at all. |
| 441 | // replace X with 0 |
| 442 | if (xm) { |
| 443 | m = 0 |
| 444 | } |
| 445 | p = 0 |
| 446 | |
| 447 | if (gtlt === '>') { |
| 448 | // >1 => >=2.0.0 |
| 449 | // >1.2 => >=1.3.0 |
| 450 | gtlt = '>=' |
| 451 | if (xm) { |
| 452 | M = +M + 1 |
| 453 | m = 0 |
| 454 | p = 0 |
| 455 | } else { |
| 456 | m = +m + 1 |
| 457 | p = 0 |
| 458 | } |
| 459 | } else if (gtlt === '<=') { |
| 460 | // <=0.7.x is actually <0.8.0, since any 0.7.x should |
| 461 | // pass. Similarly, <=7.x is actually <8.0.0, etc. |
| 462 | gtlt = '<' |
| 463 | if (xm) { |
| 464 | M = +M + 1 |
| 465 | } else { |
| 466 | m = +m + 1 |
no test coverage detected