( files: string[], projectRootDir: string, )
| 47 | * @returns An array of Class constructors from a file |
| 48 | */ |
| 49 | export 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 | } |
no test coverage detected