MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / loadClassesFromFiles

Function loadClassesFromFiles

packages/boot/src/booters/booter-utils.ts:49–69  ·  view source on GitHub ↗
(
  files: string[],
  projectRootDir: string,
)

Source from the content-addressed store, hash-verified

47 * @returns An array of Class constructors from a file
48 */
49export function loadClassesFromFiles(
50 files: string[],
51 projectRootDir: string,
52): Constructor<{}>[] {
53 const classes: Constructor<{}>[] = [];
54 for (const file of files) {
55 debug('Loading artifact file %j', path.relative(projectRootDir, file));
56 const moduleObj = require(file);
57 for (const k in moduleObj) {
58 const exported = moduleObj[k];
59 if (isClass(exported)) {
60 debug(' add %s (class %s)', k, exported.name);
61 classes.push(exported);
62 } else {
63 debug(' skip non-class %s', k);
64 }
65 }
66 }
67
68 return classes;
69}

Callers 2

loadMethod · 0.90

Calls 1

isClassFunction · 0.85

Tested by

no test coverage detected