"use strict";
const installed = globalThis.__SUPERCOV_DIRECT_RUNTIME__ ?? process.__SUPERCOV_DIRECT_RUNTIME__;
if (installed) {
globalThis.__SUPERCOV_DIRECT_RUNTIME__ ??= installed;
}
else {
try {
const fs = require("node:fs");
const path = require("node:path");
const root = path.resolve(__dirname, "..", "..");
const settings = JSON.parse(fs.readFileSync(path.join(__dirname, "run.json"), "utf8"));
const hostVisible = settings.root !== root && fs.existsSync(path.join(settings.root, ".supercov"));
const here = hostVisible ? settings.root : root;
const moved = (value) => typeof value === "string" && settings.root !== here
? value.split(settings.root).join(here)
: value;
const foreign = process.env.SUPERCOV_PROJECT_ROOT !== here;
for (const [name, value] of Object.entries(settings.environment)) {
if (foreign || process.env[name] === undefined)
process.env[name] = moved(value);
}
process.env.SUPERCOV_PROJECT_ROOT = here;
process.env.SUPERCOV_EXECUTION_LOG_SHARD ??= `bootstrap-${process.pid}-${Date.now()}`;
require("./runtime.mjs");
require("./launchSupervisor.mjs").recordExecution({ event: "guest-process", guestRoot: here });
}
catch {
}
}
module.exports = globalThis.__SUPERCOV_DIRECT_RUNTIME__;