@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
46 lines • 1.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.flowrVersion = flowrVersion;
exports.retrieveVersionInformation = retrieveVersionInformation;
exports.printVersionInformation = printVersionInformation;
const semver_1 = require("semver");
const assert_1 = require("./assert");
// this is automatically replaced with the current version by release-it
const version = '2.10.1';
/**
* Retrieves the current flowR version as a new {@link SemVer} object.
*/
function flowrVersion() {
return new semver_1.SemVer(version);
}
const versionRegex = /^\d+\.\d+\.\d+/m;
/**
* Retrieves the version information for flowR and the given parser or analysis provider.
*/
async function retrieveVersionInformation(input) {
const flowr = flowrVersion().toString();
let r;
let name;
if ('name' in input) {
r = await input.rVersion();
name = input.name;
}
else {
const parserInformation = input.parserInformation();
r = parserInformation.name === 'r-shell' ? (await parserInformation.rVersion()) : 'unknown';
name = parserInformation.name;
}
(0, assert_1.guard)(versionRegex.test(flowr), `flowR version ${flowr} does not match the expected format!`);
(0, assert_1.guard)(r === 'unknown' || r === 'none' || versionRegex.test(r), `R version ${r} does not match the expected format!`);
return { flowr: flowr, r: r, engine: name };
}
/**
* Displays the version information to the given output.
*/
async function printVersionInformation(output, input) {
const { flowr, r, engine } = await retrieveVersionInformation(input);
output.stdout(`Engine: ${engine}`);
output.stdout(` flowR: ${flowr}`);
output.stdout(` R: ${r}`);
}
//# sourceMappingURL=version.js.map