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

fix: refactor isValidSemver to avoid Invalid Version errors

parent 523b02fb
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,6 @@ const {
patch: getPatch,
satisfies: matchesSemver,
valid: isPinnedVersion,
validRange: isValidSemver,
} = semver;
const padRange = range => range + '.0'.repeat(3 - range.split('.').length);
......@@ -28,6 +27,9 @@ const getMajor = input => {
const isRange = input => isValidSemver(input) && !isPinnedVersion(input);
// If this is left as an alias, inputs like "17.04.0" throw errors
const isValidSemver = input => semver.validRange(input);
module.exports = {
getMajor,
getMinor,
......
const semver = require('../../lib/util/semver');
describe('.isValidSemver(input)', () => {
it('should return null for irregular versions', () => {
expect(!!semver.isValidSemver('17.04.0')).toBe(false);
});
it('should support simple semver', () => {
expect(!!semver.isValidSemver('1.2.3')).toBe(true);
});
......
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