Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 2x 2x 2x 6x 6x 6x 6x 6x 6x 6x 2x 6x 6x 6x | import { SemVer, gte } from 'semver';
import * as fs from 'fs';
import * as path from 'path';
function getPackageJsonVersion(path: string, moduleName = '@bb-cli/schematics'): SemVer | null {
if (fs.existsSync(path)) {
const content = fs.readFileSync(path, 'utf-8');
if (content) {
const { name, version } = JSON.parse(content);
if (name === moduleName && version) {
return new SemVer(version);
}
}
}
return null;
}
function getLocalPackageVersion(moduleName: string): SemVer | null {
return getPackageJsonVersion(path.join(process.cwd(), `node_modules/${moduleName}/package.json`), moduleName);
}
export function hasMinimumPackageVersion(packageName: string, version: string, notFoundResponse = false): boolean {
const installedVersion = getLocalPackageVersion(packageName);
Iif (!installedVersion) {
return notFoundResponse;
}
return gte(installedVersion, version);
}
|