"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.start = start;
const dotenv_1 = require("dotenv");
const harper_logger_js_1 = __importDefault(require("../utility/logging/harper_logger.js"));
function start({ override }) {
    return {
        handleFile: (contents, _, filePath) => {
            harper_logger_js_1.default.debug(`Loading env file: ${filePath}`);
            for (const [key, value] of Object.entries((0, dotenv_1.parse)(contents))) {
                if (process.env[key] !== undefined) {
                    harper_logger_js_1.default.warn(`Environment variable conflict: ${key} from ${filePath} is already set on process.env`);
                    if (override) {
                        harper_logger_js_1.default.debug(`override option enabled. overriding environment variable: ${key}`);
                    }
                    else {
                        continue;
                    }
                }
                process.env[key] = value;
            }
        },
    };
}
//# sourceMappingURL=loadEnv.js.map