Skip to content

Commit

Permalink
fix(@angular/cli): fix import path for component when importing into …
Browse files Browse the repository at this point in the history
…a module

This is similar to 86021a0.

Fix #7135
  • Loading branch information
andrewkww authored and hansl committed Aug 23, 2017
1 parent 0411d65 commit cc32f56
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/@angular/cli/blueprints/component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,11 @@ export default Blueprint.extend({
const returns: Array<any> = [];
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 normalizeRelativeDir = componentDir.startsWith('.') ? componentDir : `./${componentDir}`;
const importPath = componentDir ? `${normalizeRelativeDir}/${fileName}` : `./${fileName}`;
const fullGeneratePath = path.join(this.project.root, this.generatePath);
const moduleDir = path.parse(this.pathToModule).dir;
const relativeDir = path.relative(moduleDir, fullGeneratePath);
const normalizeRelativeDir = relativeDir.startsWith('.') ? relativeDir : `./${relativeDir}`;
const importPath = relativeDir ? `${normalizeRelativeDir}/${fileName}` : `./${fileName}`;

if (!options.skipImport) {
if (options.dryRun) {
Expand Down

0 comments on commit cc32f56

Please sign in to comment.