UNPKG

@topgroup/diginext

Version:

A BUILD SERVER & CLI to deploy apps to any Kubernetes clusters.

32 lines (31 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatEnvVars = void 0; const lodash_1 = require("lodash"); const formatEnvVars = (envVars) => { /** * {Object} envVars * @example * { * "0": { name: "NAME", value: "VALUE" }, * "1": { name: "NAME", value: "VALUE" }, * ... * } */ // check if envVars is an object if (!(0, lodash_1.isArray)(envVars)) envVars = Object.values(envVars); // convert envVars to array of { name, value } return envVars.map(({ name, value }) => { return { name, value: value ? value.toString() : "" }; // if (isString(name) && isString(value)) return { name, value }; // if (isNumber(value) || isBoolean(value) || isDate(value)) return { name, value: value.toString() }; // let valueStr: string; // // try to cast {Object} to {string} // try { // valueStr = JSON.stringify(value); // } catch (e: any) {} // return { name, value: valueStr ?? value?.toString() ?? "" }; }); }; exports.formatEnvVars = formatEnvVars;