File: /home/frenchy/www/french-american.org/current/node_modules/snyk-php-plugin/dist/system-deps.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var os = require("os");
var cmds = require("./composer-cmds");
function isSet(variable) {
return typeof variable !== 'undefined';
}
function systemDeps(basePath, options) {
var composerOk = isSet(options.composerIsFine) ? options.composerIsFine : cmds.cmdReturnsOk(cmds.composerCmd);
var composerPharOk = isSet(options.composerPharIsFine) ?
options.composerPharIsFine : cmds.cmdReturnsOk(cmds.pharCmd);
var finalVersionsObj = {};
if (options.systemVersions && (Object.keys(options.systemVersions).length > 0)) {
// give first preference to a stub
finalVersionsObj = options.systemVersions;
}
else if (composerOk) {
var lines = cmds.execWithResult(cmds.composerShowCmd, basePath).split(os.EOL);
lines.forEach(function (line) {
var _a = line.split(/\s+/), part1 = _a[0], part2 = _a[1];
if (part2) {
finalVersionsObj[part1] = part2;
}
});
}
else if (composerPharOk) {
var output = cmds.execWithResult(cmds.pharCmd, basePath);
var versionsObj = JSON.parse(output).platform;
versionsObj.forEach(function (_a) {
var name = _a.name, version = _a.version;
finalVersionsObj[name] = version;
});
}
else {
// TODO: tell the user we are not reporting accurately system versions, so some version info may not be exact
}
return finalVersionsObj;
}
exports.systemDeps = systemDeps;
//# sourceMappingURL=system-deps.js.map