Skip to content

ng g directive generate wrong import in a module #2762

Closed
@akomm

Description

@akomm

OS?

Ubuntu 14.04 lts

Versions.

angular-cli: 1.0.0-beta.17
node: 5.6.0

Repro steps.

  • ng new test
  • cd test
  • ng g module modulename
  • cd src/app/modulename
  • ng g directive directivename

The log given by the failure.

No failure

Expected result

Generates files:

  • src/app/modulename/modulename.module.ts
  • src/app/modulename/modulename.component.ts
  • src/app/modulename/modulename.component..spec.ts
  • src/app/modulename/modulename.component.html
  • src/app/modulename/modulename.component.css
  • src/app/modulename/directivename/directivename.directive.ts
  • src/app/modulename/directivename/directivename.directive.spec.ts

Content of src/app/modulename/modulename.module.ts:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ModulenameComponent } from './modulename.component';
import { DirectivenameDirective } from './directivename/directivename.directive';

@NgModule({
  imports: [
    CommonModule
  ],
  declarations: [ModulenameComponent, DirectivenameDirective]
})
export class ModulenameModule { }

Actual result (what's wrong - DIFF)

  • src/app/modulename/directivename.directive.ts
  • src/app/modulename/directivename.directive.spec.ts

Content of src/app/modulename/modulename.module.ts:

// ...
import { DirectivenameDirective } from './modulename/directivename.directive';
// ...

Problem

  1. ng g directive does not behave like ng g component, which generate output similar to the expected one.
  2. Ignoring the 1. problem, it still generates wrong import path, resolving relative to src/app and not src/app/module.

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions