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

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ module.exports = {
124124
const returns = [];
125125
const className = stringUtils.classify(`${options.entity.name}Component`);
126126
const fileName = stringUtils.dasherize(`${options.entity.name}.component`);
127-
const componentDir = path.relative(path.dirname(this.pathToModule), this.generatePath);
127+
const componentDir = path.relative(path.dirname(this.pathToModule), this.generatePath).toLowerCase();
128128
const importPath = componentDir ? `./${componentDir}/${fileName}` : `./${fileName}`;
129129

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

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

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

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

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module.exports = {
7575
const fileName = stringUtils.dasherize(`${options.entity.name}.pipe`);
7676
const fullGeneratePath = path.join(this.project.root, this.generatePath);
7777
const moduleDir = path.parse(this.pathToModule).dir;
78-
const relativeDir = path.relative(moduleDir, fullGeneratePath);
78+
const relativeDir = path.relative(moduleDir, fullGeneratePath).toLowerCase();
7979
const importPath = 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

+2-2
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
export default function() {
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+
export default function() {
7+
const rootDir = join('src', 'app', 'upper-dir');
8+
const componentDir = join(rootDir.toLowerCase(), 'test-component');
9+
createDir(rootDir);
10+
11+
return ng('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)