All files / src/utils initHandler.ts

88.88% Statements 16/18
50% Branches 2/4
100% Functions 6/6
88.23% Lines 15/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35              1x 2x 1x 1x 1x 1x               1x 1x 2x     1x 1x 1x 2x 2x     1x    
import type { ICoreKernelModule, ILogChannel, WorkLoad } from '../lib';
import CoreBridge from '../classes/CoreBridge';
 
export default async function initHandler(
  modList: ICoreKernelModule<any, any, any, any, any>[],
  logger: ILogChannel,
): Promise<void> {
  modList.forEach((src) => {
    src.getDependencyList().forEach((dep) => {
      const tar = modList.find((mod) => mod.getName() === dep);
      if (tar) {
        const bridge = new CoreBridge(src, tar);
        bridge.connect();
      } else E{
        logger.error(`DEPENDING MOD NOT FOUND: ${dep}`);
        process.exit(4);
      }
    });
  });
 
  const workload: WorkLoad<any> = [];
  modList.forEach((action) => {
    workload.push(action.register());
  });
 
  await Promise.all(workload);
  const workloadStart: WorkLoad<any> = [];
  modList.forEach((action) => {
    Eif (action?.start) {
      workloadStart.push(action.start());
    }
  });
  await Promise.all(workloadStart);
}