All files / nodejs-test-workers/src get-worker.ts

80% Statements 4/5
50% Branches 1/2
100% Functions 1/1
80% Lines 4/5

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      1x 1x     1x     1x    
/* eslint-disable n/no-sync */
import { existsSync } from 'node:fs';
 
export const getWorkerFile = (name: string): string => {
  const filePath = new URL(`../dist/workers/${name}.mjs`, import.meta.url)
    .pathname;
  // Check that the file exists
  Iif (!existsSync(filePath)) {
    throw new Error(`Worker file ${name} not found`);
  }
  return filePath;
};