fix(release): harden desktop recovery workflows

This commit is contained in:
Mohamed Boudra
2026-03-12 22:41:34 +07:00
parent fe84c5c9a3
commit defcc54af2
2 changed files with 53 additions and 1 deletions

View File

@@ -0,0 +1,20 @@
const fs = require("fs");
const path = require("path");
const Module = require("module");
const metroPackageRoot = path.dirname(require.resolve("metro-config/package.json"));
const metroLoadConfigPath = path.join(metroPackageRoot, "src", "loadConfig.js");
const originalJsLoader = Module._extensions[".js"];
Module._extensions[".js"] = function patchedMetroConfigLoader(module, filename) {
if (filename === metroLoadConfigPath) {
let source = fs.readFileSync(filename, "utf8");
source = source.replace(
"const configModule = await import(absolutePath);",
"const { pathToFileURL } = require('node:url');\n const configModule = await import(pathToFileURL(absolutePath).href);",
);
return module._compile(source, filename);
}
return originalJsLoader(module, filename);
};