Skip to content

Commit 84634cc

Browse files
amcdnljelbourn
authored andcommitted
fix(schematics): add app prefix to components (#11738)
1 parent 8be6d45 commit 84634cc

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/lib/schematics/utils/devkit-utils/component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,17 @@ function addDeclarationToNgModule(options: any): Rule {
8282
};
8383
}
8484

85-
86-
function buildSelector(options: any) {
85+
function buildSelector(options: any, projectPrefix: string) {
8786
let selector = strings.dasherize(options.name);
8887
if (options.prefix) {
8988
selector = `${options.prefix}-${selector}`;
89+
} else if (options.prefix === undefined && projectPrefix) {
90+
selector = `${projectPrefix}-${selector}`;
9091
}
9192

9293
return selector;
9394
}
9495

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

108-
options.selector = options.selector || buildSelector(options);
108+
options.selector = options.selector || buildSelector(options, project.prefix);
109109
options.module = findModuleFromOptions(host, options);
110110

111111
const parsedPath = parseName(options.path, options.name);

src/lib/schematics/utils/devkit-utils/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ export interface Workspace {
4949
export interface Project {
5050
name: string;
5151

52+
/** Application prefix. */
53+
prefix: string;
54+
5255
/** Project type. */
5356
projectType: 'application' | 'library';
5457
/** Root of the project sourcefiles. */

0 commit comments

Comments
 (0)