import { readFileSync } from "fs"; import { fileURLToPath } from "url"; import { dirname, join } from "path"; import { findUpSync } from "find-up"; // Get the directory path of the current module const currentDir = dirname(fileURLToPath(import.meta.url)); //will load and keep it in memeory since assets won't change (i.e static assests) let workerFramework: string; export const getWorkerFramework = () => { if (workerFramework) return workerFramework; const fileBuffer = readFileSync( join(currentDir, "./framework/workerFramework.js") ); const bufferToString = Buffer.from(fileBuffer).toString(); workerFramework = bufferToString; return workerFramework; }; export const getResocketDir = () => { const closestParentNodeModulesPath = findUpSync("node_modules", { type: "directory", }); if (!closestParentNodeModulesPath) throw new Error("no nodemodules found"); const resocketDir = join(closestParentNodeModulesPath, "..", ".resocket"); return resocketDir; };