Skip to content

Commit

Permalink
refactor: Exclude isSemVerRange utility
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Feb 28, 2024
1 parent 259386a commit 0e869a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/setup-dependency/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

const { resolve } = require("path")
, log = require("log").get("npm-cross-link")
, semver = require("semver")
, getNpmModulesPath = require("../get-npm-modules-path")
, setupExternal = require("./setup-external")
, setupLocal = require("./setup-local")
, resolveLogLevel = require("./resolve-log-level");
, resolveLogLevel = require("./resolve-log-level")
, isSemVerRange = require("../utils/is-sem-ver-range");

const getVersionRange = ({ dependentContext, name }) => {
if (
Expand All @@ -30,11 +30,6 @@ const getVersionRange = ({ dependentContext, name }) => {
return null;
};

const isSemVerValidRange = versionRange => {
if (versionRange === "latest") return true;
return semver.validRange(versionRange);
};

module.exports = async (dependencyContext, userConfiguration, inputOptions, progressData) => {
const { dependentContext, name, isExternal } = dependencyContext;

Expand All @@ -46,7 +41,7 @@ module.exports = async (dependencyContext, userConfiguration, inputOptions, prog
if (!dependencyContext.versionRange) dependencyContext.versionRange = packageJsonVersionRange;
const { versionRange } = dependencyContext;
if (versionRange) {
dependencyContext.isSemVerVersionRange = isSemVerValidRange(dependencyContext.versionRange);
dependencyContext.isSemVerVersionRange = isSemVerRange(dependencyContext.versionRange);
if (!dependencyContext.isSemVerVersionRange) {
log[resolveLogLevel(dependentContext, progressData)](
"%s references %s not by semver range %s", dependentContext.name, name, versionRange
Expand Down
8 changes: 8 additions & 0 deletions lib/utils/is-sem-ver-range.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"use strict";

const semver = require("semver");

module.exports = versionRange => {
if (versionRange === "latest") return true;
return semver.validRange(versionRange);
};

0 comments on commit 0e869a6

Please sign in to comment.