@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
42 lines • 2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FlowrAnalyzerMetaDescriptionFilePlugin = void 0;
const flowr_analyzer_package_versions_plugin_1 = require("./flowr-analyzer-package-versions-plugin");
const flowr_analyzer_description_file_plugin_1 = require("../file-plugins/flowr-analyzer-description-file-plugin");
const semver_1 = require("semver");
const flowr_file_1 = require("../../context/flowr-file");
/**
* This plugin extracts package meta information from R `DESCRIPTION` files.
*/
class FlowrAnalyzerMetaDescriptionFilePlugin extends flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin {
name = 'flowr-analyzer-meta-file-plugin';
description = 'This plugin does extract package meta information from R DESCRIPTION files.';
version = new semver_1.SemVer('0.1.0');
process(ctx) {
const descFiles = ctx.files.getFilesByRole(flowr_file_1.FileRole.Description);
if (descFiles.length === 0) {
flowr_analyzer_description_file_plugin_1.descriptionFileLog.debug('No description file found, cannot extract package versions.');
return;
}
else if (descFiles.length > 1) {
flowr_analyzer_description_file_plugin_1.descriptionFileLog.warn(`Found ${descFiles.length} description files, expected exactly one.`);
}
/** this will do the caching etc. for me */
const deps = descFiles[0];
const pkg = deps.packageName();
if (pkg) {
ctx.meta.setNamespace(pkg);
ctx.meta.setProjectName(pkg);
}
const ver = deps.version();
if (ver) {
ctx.meta.setProjectVersion(ver);
}
const title = deps.packageTitle();
if (title) {
ctx.meta.setProjectTitle(title);
}
}
}
exports.FlowrAnalyzerMetaDescriptionFilePlugin = FlowrAnalyzerMetaDescriptionFilePlugin;
//# sourceMappingURL=flowr-analyzer-meta-description-file-plugin.js.map