Skip to content

Commit

Permalink
bug(generate): ensure classes and imports are in lower case (#2920)
Browse files Browse the repository at this point in the history
Fixes #2833
  • Loading branch information
Brocco authored and hansl committed Nov 1, 2016
1 parent 30cc482 commit cabc9dc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/angular-cli/blueprints/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ module.exports = {
const returns = [];
const className = stringUtils.classify(`${options.entity.name}Component`);
const fileName = stringUtils.dasherize(`${options.entity.name}.component`);
const componentDir = path.relative(path.dirname(this.pathToModule), this.generatePath);
const componentDir = path.relative(path.dirname(this.pathToModule), this.generatePath).toLowerCase();
const importPath = componentDir ? `./${componentDir}/${fileName}` : `./${fileName}`;

if (!options['skip-import']) {
Expand Down
2 changes: 1 addition & 1 deletion packages/angular-cli/blueprints/directive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module.exports = {
const fileName = stringUtils.dasherize(`${options.entity.name}.directive`);
const fullGeneratePath = path.join(this.project.root, this.generatePath);
const moduleDir = path.parse(this.pathToModule).dir;
const relativeDir = path.relative(moduleDir, fullGeneratePath);
const relativeDir = path.relative(moduleDir, fullGeneratePath).toLowerCase();
const importPath = relativeDir ? `./${relativeDir}/${fileName}` : `./${fileName}`;

if (!options['skip-import']) {
Expand Down
2 changes: 1 addition & 1 deletion packages/angular-cli/blueprints/pipe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ module.exports = {
const fileName = stringUtils.dasherize(`${options.entity.name}.pipe`);
const fullGeneratePath = path.join(this.project.root, this.generatePath);
const moduleDir = path.parse(this.pathToModule).dir;
const relativeDir = path.relative(moduleDir, fullGeneratePath);
const relativeDir = path.relative(moduleDir, fullGeneratePath).toLowerCase();
const importPath = relativeDir ? `./${relativeDir}/${fileName}` : `./${fileName}`;

if (!options['skip-import']) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {join} from 'path';
import {ng} from '../../utils/process';
import {expectFileToExist} from '../../utils/fs';
import {ng} from '../../../utils/process';
import {expectFileToExist} from '../../../utils/fs';


export default function() {
Expand Down
20 changes: 20 additions & 0 deletions tests/e2e/tests/generate/component/component-path-case.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {join} from 'path';
import {ng} from '../../../utils/process';
import {expectFileToExist, createDir} from '../../../utils/fs';


export default function() {
const rootDir = join('src', 'app', 'upper-dir');
const componentDir = join(rootDir.toLowerCase(), 'test-component');
createDir(rootDir);

return ng('generate', 'component', 'Upper-Dir', 'test-component')
.then(() => expectFileToExist(componentDir))
.then(() => expectFileToExist(join(componentDir, 'test-component.component.ts')))
.then(() => expectFileToExist(join(componentDir, 'test-component.component.spec.ts')))
.then(() => expectFileToExist(join(componentDir, 'test-component.component.html')))
.then(() => expectFileToExist(join(componentDir, 'test-component.component.css')))

// Try to run the unit tests.
.then(() => ng('test', '--watch=false'));
}

0 comments on commit cabc9dc

Please sign in to comment.