1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const os = require("os");
|
4 | const cmds = require("./composer-cmds");
|
5 | function isSet(variable) {
|
6 | return typeof variable !== 'undefined';
|
7 | }
|
8 | function systemDeps(basePath, options) {
|
9 | const composerOk = isSet(options.composerIsFine) ? options.composerIsFine : cmds.cmdReturnsOk(cmds.composerCmd);
|
10 | const composerPharOk = isSet(options.composerPharIsFine) ?
|
11 | options.composerPharIsFine : cmds.cmdReturnsOk(cmds.pharCmd);
|
12 | let finalVersionsObj = {};
|
13 | if (options.systemVersions && (Object.keys(options.systemVersions).length > 0)) {
|
14 |
|
15 | finalVersionsObj = options.systemVersions;
|
16 | }
|
17 | else if (composerOk) {
|
18 | const lines = cmds.execWithResult(cmds.composerShowCmd, basePath).split(os.EOL);
|
19 | lines.forEach((line) => {
|
20 | const [part1, part2] = line.split(/\s+/);
|
21 | if (part2) {
|
22 | finalVersionsObj[part1] = part2;
|
23 | }
|
24 | });
|
25 | }
|
26 | else if (composerPharOk) {
|
27 | const output = cmds.execWithResult(cmds.pharCmd, basePath);
|
28 | const versionsObj = JSON.parse(output).platform;
|
29 | versionsObj.forEach(({ name, version }) => {
|
30 | finalVersionsObj[name] = version;
|
31 | });
|
32 | }
|
33 | else {
|
34 |
|
35 | }
|
36 | return finalVersionsObj;
|
37 | }
|
38 | exports.systemDeps = systemDeps;
|
39 |
|
\ | No newline at end of file |