All files / utils get-project-root.ts

100% Statements 12/12
100% Branches 3/3
100% Functions 1/1
100% Lines 11/11

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    6x 50x   50x 1x     49x 1x       48x   48x 1x     47x   47x    
import { ExecutorContext } from '@nx/devkit';
 
export const getProjectRoot = (context: ExecutorContext): string => {
  const projectName = context.projectName;
 
  if (!projectName) {
    throw new Error("Project name isn't defined");
  }
 
  if (!context.projectsConfigurations) {
    throw new Error("Projects configurations aren't defined");
  }
 
  const projectConfiguration =
    context.projectsConfigurations.projects[projectName];
 
  if (!projectConfiguration) {
    throw new Error(`Project configuration '${projectName}' isn't defined.`);
  }
 
  const { root } = projectConfiguration;
 
  return root;
};