MCPcopy
hub / github.com/vercel/hyper / requirePlugins

Function requirePlugins

app/plugins.ts:275–313  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

273};
274
275function requirePlugins(): any[] {
276 const {plugins: plugins_, localPlugins} = paths;
277
278 const load = (path_: string) => {
279 let mod: any;
280 try {
281 mod = require(path_);
282 const exposed = mod && Object.keys(mod).some((key) => availableExtensions.has(key));
283 if (!exposed) {
284 notify('Plugin error!', `${`Plugin "${basename(path_)}" does not expose any `}Hyper extension API methods`);
285 return;
286 }
287
288 // populate the name for internal errors here
289 mod._name = basename(path_);
290 try {
291 // eslint-disable-next-line @typescript-eslint/no-var-requires
292 mod._version = require(resolve(path_, 'package.json')).version;
293 } catch (err) {
294 console.warn(`No package.json found in ${path_}`);
295 }
296 console.log(`Plugin ${mod._name} (${mod._version}) loaded.`);
297
298 return mod;
299 } catch (_err) {
300 const err = _err as {code: string; message: string};
301 if (err.code === 'MODULE_NOT_FOUND') {
302 console.warn(`Plugin error while loading "${basename(path_)}" (${path_}): ${err.message}`);
303 } else {
304 notify('Plugin error!', `Plugin "${basename(path_)}" failed to load (${err.message})`, {error: err});
305 }
306 }
307 };
308
309 return plugins_
310 .map(load)
311 .concat(localPlugins.map(load))
312 .filter((v) => Boolean(v));
313}
314
315export const onApp = (app_: App) => {
316 modules.forEach((plugin) => {

Callers 2

plugins.tsFile · 0.85
updatePluginsFunction · 0.85

Calls 2

filterMethod · 0.80
concatMethod · 0.80

Tested by

no test coverage detected