( workspace: WorkspaceDefinition, projectName: string | undefined, )
| 14 | * couldn't be found. |
| 15 | */ |
| 16 | export function getProjectFromWorkspace( |
| 17 | workspace: WorkspaceDefinition, |
| 18 | projectName: string | undefined, |
| 19 | ): ProjectDefinition { |
| 20 | if (!projectName) { |
| 21 | // TODO(crisbeto): some schematics APIs have the project name as optional so for now it's |
| 22 | // simpler to allow undefined and checking it at runtime. Eventually we should clean this up. |
| 23 | throw new SchematicsException('Project name is required.'); |
| 24 | } |
| 25 | |
| 26 | const project = workspace.projects.get(projectName); |
| 27 | |
| 28 | if (!project) { |
| 29 | throw new SchematicsException(`Could not find project in workspace: ${projectName}`); |
| 30 | } |
| 31 | |
| 32 | return project; |
| 33 | } |
no test coverage detected