MCPcopy
hub / github.com/smapiot/piral / requireModule

Function requireModule

src/framework/piral-base/src/utils/system.ts:187–198  ·  view source on GitHub ↗
(name: string, parent: string)

Source from the content-addressed store, hash-verified

185 * @returns The module's content, if any, otherwise throws an error.
186 */
187export function requireModule(name: string, parent: string) {
188 const moduleId = tryResolve(name, parent);
189 const dependency = moduleId && System.get(moduleId);
190
191 if (!dependency) {
192 const error: any = new Error(`Cannot find module '${name}'`);
193 error.code = 'MODULE_NOT_FOUND';
194 throw error;
195 }
196
197 return dependency;
198}

Callers 2

includeScriptFunction · 0.90
requireFunction · 0.90

Calls 2

getMethod · 0.80
tryResolveFunction · 0.70

Tested by

no test coverage detected