Skip to content

Commit

Permalink
fix(schematics): add app prefix to components (angular#11738)
Browse files Browse the repository at this point in the history
  • Loading branch information
amcdnl authored and jelbourn committed Jun 13, 2018
1 parent 8be6d45 commit 84634cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib/schematics/utils/devkit-utils/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ function addDeclarationToNgModule(options: any): Rule {
};
}


function buildSelector(options: any) {
function buildSelector(options: any, projectPrefix: string) {
let selector = strings.dasherize(options.name);
if (options.prefix) {
selector = `${options.prefix}-${selector}`;
} else if (options.prefix === undefined && projectPrefix) {
selector = `${projectPrefix}-${selector}`;
}

return selector;
}


export function buildComponent(options: any): Rule {
return (host: Tree, context: SchematicContext) => {
const workspace = getWorkspace(host);
Expand All @@ -105,7 +105,7 @@ export function buildComponent(options: any): Rule {
options.path = `/${project.root}/src/app`;
}

options.selector = options.selector || buildSelector(options);
options.selector = options.selector || buildSelector(options, project.prefix);
options.module = findModuleFromOptions(host, options);

const parsedPath = parseName(options.path, options.name);
Expand Down
3 changes: 3 additions & 0 deletions src/lib/schematics/utils/devkit-utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export interface Workspace {
export interface Project {
name: string;

/** Application prefix. */
prefix: string;

/** Project type. */
projectType: 'application' | 'library';
/** Root of the project sourcefiles. */
Expand Down

0 comments on commit 84634cc

Please sign in to comment.