"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getChildEnv = getChildEnv;
const tslib_1 = require("tslib");
const is_1 = tslib_1.__importDefault(require("@sindresorhus/is"));
const global_1 = require("../../config/global");
const env_1 = require("./env");
function getChildEnv({ extraEnv, userConfiguredEnv, env: forcedEnv = {}, }) {
    const globalConfigEnv = global_1.GlobalConfig.get('customEnvVariables');
    const inheritedKeys = [];
    for (const [key, val] of Object.entries(extraEnv ?? {})) {
        if (is_1.default.string(val)) {
            inheritedKeys.push(key);
        }
    }
    const parentEnv = (0, env_1.getChildProcessEnv)(inheritedKeys);
    const combinedEnv = {
        ...extraEnv,
        ...parentEnv,
        ...globalConfigEnv,
        ...userConfiguredEnv,
        ...forcedEnv,
    };
    const result = {};
    for (const [key, val] of Object.entries(combinedEnv)) {
        if (is_1.default.string(val)) {
            result[key] = `${val}`;
        }
    }
    return result;
}
//# sourceMappingURL=utils.js.map