Skip to content

Commit 4875aa7

Browse files
committed
fix(page): properly handle project selection
Fixes #34
1 parent 75cc24e commit 4875aa7

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

schematics/page/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { Path, join, normalize, strings } from '@angular-devkit/core';
22
import { DirEntry, Rule, SchematicsException, Tree, apply, branchAndMerge, chain, filter, mergeWith, move, noop, template, url } from '@angular-devkit/schematics';
33
import { findNodes } from '@schematics/angular/utility/ast-utils';
44
import { Change, InsertChange } from '@schematics/angular/utility/change';
5-
import { getWorkspace } from '@schematics/angular/utility/config';
65
import { ModuleOptions, buildRelativePath } from '@schematics/angular/utility/find-module';
76
import { parseName } from '@schematics/angular/utility/parse-name';
7+
import { buildDefaultPath, getProject } from '@schematics/angular/utility/project';
88
import { validateHtmlSelector, validateName } from '@schematics/angular/utility/validation';
99
import * as ts from 'typescript';
1010

@@ -151,16 +151,14 @@ function buildSelector(options: PageOptions, projectPrefix: string) {
151151

152152
export default function(options: PageOptions): Rule {
153153
return (host, context) => {
154-
const workspace = getWorkspace(host);
155-
156154
if (!options.project) {
157-
options.project = Object.keys(workspace.projects)[0];
155+
throw new SchematicsException('Option (project) is required.');
158156
}
159157

160-
const project = workspace.projects[options.project];
158+
const project = getProject(host, options.project);
161159

162160
if (options.path === undefined) {
163-
options.path = `/${project.root}/src/app`;
161+
options.path = buildDefaultPath(project);
164162
}
165163

166164
options.module = findRoutingModuleFromOptions(host, options);

0 commit comments

Comments
 (0)