(
workspace: workspaces.WorkspaceDefinition,
options: { project?: string | undefined; path?: string | undefined },
typeFilter: 'application' | 'library' | null = null,
)
| 25 | } |
| 26 | |
| 27 | export 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 | |
| 54 | export const getSourceRoot = (sourceRoot: string | undefined) => |
| 55 | sourceRoot === undefined ? 'src' : normalize(sourceRoot); |
no test coverage detected