Skip to content

Commit

Permalink
Added new semver class to file
Browse files Browse the repository at this point in the history
  • Loading branch information
brycez1 committed Jan 24, 2024
1 parent 5fcbc6d commit 13554ea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/meta/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const chalk_1 = __importDefault(require("chalk"));
const constants_1 = require("../constants");
// added "resolveJsonModule": true to tsconfig.json
const package_json_1 = __importDefault(require("../../package.json"));
class SemVer2 extends semver_1.default.SemVer {
}
const Dependencies = module.exports;
let depsMissing = false;
let depsOutdated = false;
Expand Down Expand Up @@ -65,7 +67,7 @@ Dependencies.parseModuleData = function (moduleName, pkgData) {
depsMissing = true;
return null;
}
const moduleData = new semver_1.default.SemVer(pkgData);
const moduleData = new SemVer2(pkgData);
return moduleData;
};
Dependencies.doesSatisfy = function (moduleData, packageJSONVersion) {
Expand Down
20 changes: 14 additions & 6 deletions src/meta/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@ import { paths, pluginNamePattern } from '../constants';
// added "resolveJsonModule": true to tsconfig.json
import pkg from '../../package.json';

type resolveType = {
includes(uri: string) : boolean;
}

class SemVer2 extends semver.SemVer {
_resolved?: resolveType;

name: string;
}

interface depexport {
check: () => Promise<void>;
checkModule(moduleName : string) : Promise<boolean>;
parseModuleData(moduleName : string, pkgData : string) : semver.SemVer | null;
// have to leave moduleData as any type as replacing with semver.SemVer causes file
// to not compile due to missing fields
doesSatisfy(moduleData : semver.SemVer, packageJSONVersion : string) : boolean;
parseModuleData(moduleName : string, pkgData : string) : SemVer2 | null;
doesSatisfy(moduleData : SemVer2, packageJSONVersion : string) : boolean;
}
const Dependencies : depexport = module.exports as depexport;

Expand Down Expand Up @@ -67,11 +75,11 @@ Dependencies.parseModuleData = function (moduleName, pkgData) {
depsMissing = true;
return null;
}
const moduleData = new semver.SemVer(pkgData);
const moduleData = new SemVer2(pkgData);
return moduleData;
};

Dependencies.doesSatisfy = function (moduleData : semver.SemVer, packageJSONVersion) {
Dependencies.doesSatisfy = function (moduleData, packageJSONVersion) {
if (!moduleData) {
return false;
}
Expand Down

0 comments on commit 13554ea

Please sign in to comment.