Skip to content

Commit

Permalink
fix(page): properly handle project selection
Browse files Browse the repository at this point in the history
Fixes #34
  • Loading branch information
imhoffd committed Dec 21, 2018
1 parent 75cc24e commit 4875aa7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions schematics/page/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Path, join, normalize, strings } from '@angular-devkit/core';
import { DirEntry, Rule, SchematicsException, Tree, apply, branchAndMerge, chain, filter, mergeWith, move, noop, template, url } from '@angular-devkit/schematics';
import { findNodes } from '@schematics/angular/utility/ast-utils';
import { Change, InsertChange } from '@schematics/angular/utility/change';
import { getWorkspace } from '@schematics/angular/utility/config';
import { ModuleOptions, buildRelativePath } from '@schematics/angular/utility/find-module';
import { parseName } from '@schematics/angular/utility/parse-name';
import { buildDefaultPath, getProject } from '@schematics/angular/utility/project';
import { validateHtmlSelector, validateName } from '@schematics/angular/utility/validation';
import * as ts from 'typescript';

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

export default function(options: PageOptions): Rule {
return (host, context) => {
const workspace = getWorkspace(host);

if (!options.project) {
options.project = Object.keys(workspace.projects)[0];
throw new SchematicsException('Option (project) is required.');
}

const project = workspace.projects[options.project];
const project = getProject(host, options.project);

if (options.path === undefined) {
options.path = `/${project.root}/src/app`;
options.path = buildDefaultPath(project);
}

options.module = findRoutingModuleFromOptions(host, options);
Expand Down

0 comments on commit 4875aa7

Please sign in to comment.