All files / libs/tools/plugin/src/generators/heal/healthpacks build-target.ts

89.65% Statements 26/29
66.66% Branches 4/6
100% Functions 1/1
89.65% Lines 26/29

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 301x 1x 1x 1x 1x 1x 1x 1x 15x 15x 15x 15x 15x       15x 15x 15x 15x 14x 14x 14x 1x 1x 1x 1x 1x 1x  
import { type ProjectConfiguration, type Tree } from '@nx/devkit';
import { omit } from 'lodash-es';
 
import { assert } from '@amalia/ext/typescript';
 
import { updateProjectConfiguration } from '../../helpers/project-configuration';
 
export const removeBuildTargetFromLib = (tree: Tree, projectConfiguration: ProjectConfiguration) => {
  const projectName = projectConfiguration.name;
 
  assert(projectName, `Project name missing in ${projectConfiguration.root}`);
 
  if (projectConfiguration.projectType !== 'library') {
    // ignore non-library projects
    return;
  }
 
  const buildTargetName = Object.keys(projectConfiguration.targets ?? {}).find((target) => target.includes('build'));
 
  if (!buildTargetName) {
    // Nothing to do.
    return;
  }
 
  updateProjectConfiguration(tree, projectConfiguration.root, {
    ...projectConfiguration,
    targets: omit(projectConfiguration.targets, buildTargetName),
  });
};