1 | "use strict";
|
---|
2 |
|
---|
3 | exports.__esModule = true;
|
---|
4 | exports.hasMinVersion = hasMinVersion;
|
---|
5 |
|
---|
6 | var _semver = _interopRequireDefault(require("semver"));
|
---|
7 |
|
---|
8 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
---|
9 |
|
---|
10 | function hasMinVersion(minVersion, runtimeVersion) {
|
---|
11 | // If the range is unavailable, we're running the script during Babel's
|
---|
12 | // build process, and we want to assume that all versions are satisfied so
|
---|
13 | // that the built output will include all definitions.
|
---|
14 | if (!runtimeVersion || !minVersion) return true; // semver.intersects() has some surprising behavior with comparing ranges
|
---|
15 | // with preprelease versions. We add '^' to ensure that we are always
|
---|
16 | // comparing ranges with ranges, which sidesteps this logic.
|
---|
17 | // For example:
|
---|
18 | //
|
---|
19 | // semver.intersects(`<7.0.1`, "7.0.0-beta.0") // false - surprising
|
---|
20 | // semver.intersects(`<7.0.1`, "^7.0.0-beta.0") // true - expected
|
---|
21 | //
|
---|
22 | // This is because the first falls back to
|
---|
23 | //
|
---|
24 | // semver.satisfies("7.0.0-beta.0", `<7.0.1`) // false - surprising
|
---|
25 | //
|
---|
26 | // and this fails because a prerelease version can only satisfy a range
|
---|
27 | // if it is a prerelease within the same major/minor/patch range.
|
---|
28 | //
|
---|
29 | // Note: If this is found to have issues, please also revist the logic in
|
---|
30 | // babel-core's availableHelper() API.
|
---|
31 |
|
---|
32 | if (_semver.default.valid(runtimeVersion)) runtimeVersion = `^${runtimeVersion}`;
|
---|
33 | return !_semver.default.intersects(`<${minVersion}`, runtimeVersion) && !_semver.default.intersects(`>=8.0.0`, runtimeVersion);
|
---|
34 | } |
---|