Skip to content

Directive generated from project root directory is added to wrong module #12614

Closed
@tchatel

Description

@tchatel

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [x] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

It's a regression which occurs since Angular CLI version 6.0.0 (and still occurs with latest versions 6.2.5 and 7.0.0-rc.3).
There was no problem with Angular CLI 1.7.4 / Angular 5.

Repro steps

ng new proj
cd proj
ng generate module mod
ng generate directive mod/dir

The log given by the failure

CREATE src/app/mod/dir.directive.spec.ts (212 bytes)
CREATE src/app/mod/dir.directive.ts (135 bytes)
[BUG]>> UPDATE src/app/app.module.ts (384 bytes)

Desired functionality

The directive should be added to src/app/mod/mod.module.ts, not to src/app/app.module.ts.

No problem when generating pipes and components. The bug only happens with directives, and when the command is run from the project root directory. When the command is run from the target module directory, it's ok.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions