Skip to content
Snippets Groups Projects
Commit 5fd996c9 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

refactor: use isSingleVersion not isRange

parent 8b9d4b10
No related branches found
No related tags found
No related merge requests found
......@@ -22,8 +22,6 @@ const isStable = input => {
return !version.is_prerelease;
};
const isRange = input => isValid(input) && !isVersion(input);
// If this is left as an alias, inputs like "17.04.0" throw errors
const isValid = input => validRange(input);
......@@ -47,7 +45,6 @@ module.exports = {
getMinor,
isGreaterThan,
isSingleVersion,
isRange,
isStable,
isValid,
isVersion,
......
......@@ -24,8 +24,6 @@ const getMajor = input => {
return semver.major(version);
};
const isRange = input => isValid(input) && !isVersion(input);
// If this is left as an alias, inputs like "17.04.0" throw errors
const isValid = input => validRange(input);
......@@ -39,7 +37,6 @@ module.exports = {
getMinor,
isGreaterThan,
isLessThanRange,
isRange,
isSingleVersion,
isStable,
isValid,
......
......@@ -18,7 +18,7 @@ async function lookupUpdates(config) {
getMajor,
getMinor,
isGreaterThan,
isRange,
isSingleVersion,
isVersion,
matches,
getNewValue,
......@@ -93,11 +93,11 @@ async function lookupUpdates(config) {
}
const rangeStrategy = getRangeStrategy(config);
const fromVersion = getFromVersion(config, rangeStrategy, allVersions);
if (isRange(currentValue) && rangeStrategy === 'pin') {
if (rangeStrategy === 'pin' && !isSingleVersion(currentValue)) {
updates.push({
type: 'pin',
isPin: true,
newValue: fromVersion,
newValue: getNewValue(config, fromVersion, fromVersion),
newMajor: getMajor(fromVersion),
});
}
......@@ -121,7 +121,7 @@ async function lookupUpdates(config) {
update.newMajor = getMajor(toVersion);
update.newMinor = getMinor(toVersion);
update.type = getType(config, fromVersion, toVersion);
if (isRange(update.newValue)) {
if (!isVersion(update.newValue)) {
update.isRange = true;
}
......@@ -183,10 +183,10 @@ function getBucket(config, update) {
function getFromVersion(config, rangeStrategy, allVersions) {
const { currentValue, lockedVersion, versionScheme } = config;
const { isRange, maxSatisfyingVersion, minSatisfyingVersion } = versioning(
const { isVersion, maxSatisfyingVersion, minSatisfyingVersion } = versioning(
versionScheme
);
if (!isRange(currentValue)) {
if (isVersion(currentValue)) {
return currentValue;
}
logger.trace(`currentValue ${currentValue} is range`);
......
......@@ -23,17 +23,6 @@ describe('pep440.isValid(input)', () => {
).toBe(false);
});
});
describe('pep440.isRange(input)', () => {
it('rejects simple pep440', () => {
expect(!!pep440.isRange('1.2.3')).toBe(false);
});
it('accepts tilde', () => {
expect(!!pep440.isRange('~=1.2.3')).toBe(true);
});
it('accepts glob', () => {
expect(!!pep440.isRange('==1.2.*')).toBe(true);
});
});
describe('pep440.isStable(version)', () => {
it('returns correct value', () => {
......
......@@ -26,17 +26,6 @@ describe('semver.isValid(input)', () => {
).toBe(false);
});
});
describe('semver.isRange(input)', () => {
it('rejects simple semver', () => {
expect(!!semver.isRange('1.2.3')).toBe(false);
});
it('accepts tilde', () => {
expect(!!semver.isRange('~1.2.3')).toBe(true);
});
it('accepts caret', () => {
expect(!!semver.isRange('^1.2.3')).toBe(true);
});
});
describe('semver.isSingleVersion()', () => {
it('returns true if naked version', () => {
expect(!!semver.isSingleVersion('1.2.3')).toBe(true);
......
......@@ -42,7 +42,7 @@ Array [
Object {
"isPin": true,
"newMajor": 0,
"newValue": "0.9.4",
"newValue": "==0.9.4",
"repositoryUrl": "https://github.com/kriskowal/q",
"type": "pin",
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment