@sentry/wizard
Version:
Sentry wizard helping you to configure your project
29 lines • 1.49 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPackageVersion = exports.hasPackageInstalled = exports.findInstalledPackageFromList = void 0;
/**
* Checks if @param packageJson has any of the @param packageNamesList package names
* listed as a dependency or devDependency.
* If so, it returns the first package name that is found, including the
* version (range) specified in the package.json.
*/
function findInstalledPackageFromList(packageNamesList, packageJson) {
return packageNamesList
.map(function (packageName) { return ({
name: packageName,
version: getPackageVersion(packageName, packageJson),
}); })
.find(function (sdkPackage) { return !!sdkPackage.version; });
}
exports.findInstalledPackageFromList = findInstalledPackageFromList;
function hasPackageInstalled(packageName, packageJson) {
return getPackageVersion(packageName, packageJson) !== undefined;
}
exports.hasPackageInstalled = hasPackageInstalled;
function getPackageVersion(packageName, packageJson) {
var _a, _b;
return (((_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson.dependencies) === null || _a === void 0 ? void 0 : _a[packageName]) ||
((_b = packageJson === null || packageJson === void 0 ? void 0 : packageJson.devDependencies) === null || _b === void 0 ? void 0 : _b[packageName]));
}
exports.getPackageVersion = getPackageVersion;
//# sourceMappingURL=package-json.js.map