1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.objectToArgs = exports.executeAppBuilderAndWriteJson = exports.executeAppBuilderAsJson = void 0;
|
4 | const builder_util_1 = require("builder-util");
|
5 | function executeAppBuilderAsJson(args) {
|
6 | return (0, builder_util_1.executeAppBuilder)(args).then(rawResult => {
|
7 | if (rawResult === "") {
|
8 | return Object.create(null);
|
9 | }
|
10 | try {
|
11 | return JSON.parse(rawResult);
|
12 | }
|
13 | catch (e) {
|
14 | throw new Error(`Cannot parse result: ${e.message}: "${rawResult}"`);
|
15 | }
|
16 | });
|
17 | }
|
18 | exports.executeAppBuilderAsJson = executeAppBuilderAsJson;
|
19 | function executeAppBuilderAndWriteJson(args, data, extraOptions = {}) {
|
20 | return (0, builder_util_1.executeAppBuilder)(args, childProcess => {
|
21 | childProcess.stdin.end(JSON.stringify(data));
|
22 | }, {
|
23 | ...extraOptions,
|
24 | stdio: ["pipe", "pipe", process.stdout],
|
25 | });
|
26 | }
|
27 | exports.executeAppBuilderAndWriteJson = executeAppBuilderAndWriteJson;
|
28 | function objectToArgs(to, argNameToValue) {
|
29 | for (const name of Object.keys(argNameToValue)) {
|
30 | const value = argNameToValue[name];
|
31 | if (value != null) {
|
32 | to.push(`--${name}`, value);
|
33 | }
|
34 | }
|
35 | }
|
36 | exports.objectToArgs = objectToArgs;
|
37 |
|
\ | No newline at end of file |