0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

chore: improve version detection (#2558)

This commit is contained in:
Juan Picado 2021-10-21 23:29:58 +02:00 committed by GitHub
parent f345fefd99
commit 5776015058
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View file

@ -1,7 +1,8 @@
import semver from 'semver';
export const MIN_NODE_VERSION = '14';
export const MIN_NODE_VERSION = '14.0.0';
export function isVersionValid(version) {
export function isVersionValid(processVersion) {
const version = processVersion.substr(1);
return semver.satisfies(version, `>=${MIN_NODE_VERSION}`);
}

View file

@ -1,9 +1,16 @@
import { isVersionValid } from '../src/utils';
test('valid version node.js', () => {
expect(isVersionValid('14.0.0')).toBeTruthy();
expect(isVersionValid('v14.0.0')).toBeTruthy();
expect(isVersionValid('v15.0.0')).toBeTruthy();
expect(isVersionValid('v16.0.0')).toBeTruthy();
expect(isVersionValid('v17.0.0')).toBeTruthy();
});
test('is invalid version node.js', () => {
expect(isVersionValid('13.0.0')).toBeFalsy();
expect(isVersionValid('v13.0.0')).toBeFalsy();
expect(isVersionValid('v12.0.0')).toBeFalsy();
expect(isVersionValid('v8.0.0')).toBeFalsy();
expect(isVersionValid('v4.0.0')).toBeFalsy();
expect(isVersionValid('v0.0.10')).toBeFalsy();
});