UNPKG

release-checker

Version:
40 lines (39 loc) 1.34 kB
"use strict"; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); var semver = __importStar(require("semver")); var exec_sync_1 = require("./exec-sync"); var NPM_VERSION_WITH_PACK_JSON_REPORTER = '5.9.0'; function getCurrentNpmVersion() { var result = exec_sync_1.exec('npm version --json'); try { return JSON.parse(result).npm; } catch (error) { throw new Error("Cannot parse the result of command 'npm version --json'"); } } exports.getCurrentNpmVersion = getCurrentNpmVersion; function npmPackCanReportInJson(version) { return semver.gte(version, NPM_VERSION_WITH_PACK_JSON_REPORTER); } exports.npmPackCanReportInJson = npmPackCanReportInJson; function currentNpmVersion() { var currentVersion = getCurrentNpmVersion(); return { canReportInJson: function () { return { packCommand: function () { return npmPackCanReportInJson(currentVersion); }, }; }, }; } exports.currentNpmVersion = currentNpmVersion;