Skip to content

Commit cabc9dc

Browse files
Broccohansl
authored andcommitted
bug(generate): ensure classes and imports are in lower case (#2920)
Fixes#2833
1 parent 30cc482 commit cabc9dc

5 files changed

Lines changed: 25 additions & 5 deletions

File tree

‎packages/angular-cli/blueprints/component/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ module.exports = {
124124
constreturns=[];
125125
constclassName=stringUtils.classify(`${options.entity.name}Component`);
126126
constfileName=stringUtils.dasherize(`${options.entity.name}.component`);
127-
constcomponentDir=path.relative(path.dirname(this.pathToModule),this.generatePath);
127+
constcomponentDir=path.relative(path.dirname(this.pathToModule),this.generatePath).toLowerCase();
128128
constimportPath=componentDir ? `./${componentDir}/${fileName}` : `./${fileName}`;
129129

130130
if(!options['skip-import']){

‎packages/angular-cli/blueprints/directive/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ module.exports = {
8787
constfileName=stringUtils.dasherize(`${options.entity.name}.directive`);
8888
constfullGeneratePath=path.join(this.project.root,this.generatePath);
8989
constmoduleDir=path.parse(this.pathToModule).dir;
90-
constrelativeDir=path.relative(moduleDir,fullGeneratePath);
90+
constrelativeDir=path.relative(moduleDir,fullGeneratePath).toLowerCase();
9191
constimportPath=relativeDir ? `./${relativeDir}/${fileName}` : `./${fileName}`;
9292

9393
if(!options['skip-import']){

‎packages/angular-cli/blueprints/pipe/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module.exports = {
7575
constfileName=stringUtils.dasherize(`${options.entity.name}.pipe`);
7676
constfullGeneratePath=path.join(this.project.root,this.generatePath);
7777
constmoduleDir=path.parse(this.pathToModule).dir;
78-
constrelativeDir=path.relative(moduleDir,fullGeneratePath);
78+
constrelativeDir=path.relative(moduleDir,fullGeneratePath).toLowerCase();
7979
constimportPath=relativeDir ? `./${relativeDir}/${fileName}` : `./${fileName}`;
8080

8181
if(!options['skip-import']){

tests/e2e/tests/generate/component.ts renamed to tests/e2e/tests/generate/component/component-basic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import{join}from'path';
2-
import{ng}from'../../utils/process';
3-
import{expectFileToExist}from'../../utils/fs';
2+
import{ng}from'../../../utils/process';
3+
import{expectFileToExist}from'../../../utils/fs';
44

55

66
exportdefaultfunction(){
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import{join}from'path';
2+
import{ng}from'../../../utils/process';
3+
import{expectFileToExist,createDir}from'../../../utils/fs';
4+
5+
6+
exportdefaultfunction(){
7+
constrootDir=join('src','app','upper-dir');
8+
constcomponentDir=join(rootDir.toLowerCase(),'test-component');
9+
createDir(rootDir);
10+
11+
returnng('generate','component','Upper-Dir','test-component')
12+
.then(()=>expectFileToExist(componentDir))
13+
.then(()=>expectFileToExist(join(componentDir,'test-component.component.ts')))
14+
.then(()=>expectFileToExist(join(componentDir,'test-component.component.spec.ts')))
15+
.then(()=>expectFileToExist(join(componentDir,'test-component.component.html')))
16+
.then(()=>expectFileToExist(join(componentDir,'test-component.component.css')))
17+
18+
// Try to run the unit tests.
19+
.then(()=>ng('test','--watch=false'));
20+
}

0 commit comments

Comments
 (0)