MCPcopy Create free account
hub / github.com/SoCreate/angular-playground / getProject

Function getProject

projects/schematics/src/utils/project.ts:27–52  ·  view source on GitHub ↗
(
  workspace: workspaces.WorkspaceDefinition,
  options: { project?: string | undefined; path?: string | undefined },
  typeFilter: 'application' | 'library' | null = null,
)

Source from the content-addressed store, hash-verified

25}
26
27export function getProject(
28 workspace: workspaces.WorkspaceDefinition,
29 options: { project?: string | undefined; path?: string | undefined },
30 typeFilter: 'application' | 'library' | null = null,
31): workspaces.ProjectDefinition | undefined {
32
33 if (!options.project) {
34 // can have no projects if created with `ng new <name> --createApplication=false`
35 if (workspace.projects.size === 0) {
36 throw new SchematicsException('Your app must have at least 1 project to use Playground.');
37 }
38 // if type filter is not set, use first project
39 let firstFilteredProjectName = getFirstProjectName(workspace.projects);
40 if (typeFilter) {
41 // apply filter
42 for (const [projectName, project] of workspace.projects.entries()) {
43 if (project.extensions.projectType === typeFilter) {
44 firstFilteredProjectName = projectName;
45 break;
46 }
47 }
48 }
49 options.project = firstFilteredProjectName;
50 }
51 return workspace.projects.get(options.project || '');
52}
53
54export const getSourceRoot = (sourceRoot: string | undefined) =>
55 sourceRoot === undefined ? 'src' : normalize(sourceRoot);

Callers 8

sandboxFunction · 0.90
configureFunction · 0.90
createNewFilesFunction · 0.90
configureFunction · 0.90
updateFilesFunction · 0.90
configureFunction · 0.90
createNewFilesFunction · 0.90
getProjectPathFunction · 0.85

Calls 1

getFirstProjectNameFunction · 0.85

Tested by

no test coverage detected