MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / requireOrInstall

Function requireOrInstall

quote/quote.ts:103–113  ·  view source on GitHub ↗
(pkg: string)

Source from the content-addressed store, hash-verified

101 if (old.length === data.length && old.equals(data)) return;
102 }
103 fs.writeFileSync(filePath, data);
104}
105
106function requireOrInstall(pkg: string): any {
107 try {
108 return require(pkg);
109 } catch (err: any) {
110 const code = err?.code;
111 if (code !== "MODULE_NOT_FOUND" && code !== "ERR_MODULE_NOT_FOUND") throw err;
112 console.warn("quote loader installing npm package", { pkg });
113 npm_install(pkg);
114 return require(pkg);
115 }
116}

Callers 3

getSharpFunction · 0.85
getCanvasFunction · 0.85
getQuoteGenFunction · 0.85

Calls 1

warnMethod · 0.80

Tested by

no test coverage detected