Skip to content

Yo doesn't check parent directories for yo-rc.json #1291

@juliankrieger

Description

@juliankrieger

Type of issue: Bug

My environment

  • OS version/details: MacOs 11.13
  • Node version: 14.16.1 (run node --version in your terminal)
  • npm version: 6.14.12 (run npm --version in your terminal)
  • Version of yo : 4.0.0 (run yo --version in your terminal)

Expected behavior

Yo correctly determines tmp (or whatever folder it was first run in) as the project root, and places files correctly even when run from a subdirectory. The subdirectory is not mistakenly marked as a new project root, the subdirectory does not mistakenly include a yo-rc.json itself.

Current behavior

  1. Instead of creating new files in tmp/files, the following file structure occurs
tmp
│   yo-rc.json    
└───files
│       │   <files here>
└───subdir
│   │   yo-rc.json
│   └───subfolder
│       │   <files here>

Steps to reproduce the behavior

  1. Set up simple project
  2. Create a "new" BaseGenerator, which all other generators extend from
  3. Write an initialise function as follows
_initialize() {
        const defaults: Config = {
          // Some defaults here
        }

        this.config.defaults(defaults)
    }
  1. In each Generator or Subgenerator, call _initialise in the initializing context. Generators create files either with this.destinationRoot or any configuration option in the config
  2. Setup Generator with npm link
  3. Create a directory, we'll call it tmp
  4. Run generator in tmp
  5. Observe it working as intended. Files are created in tmp/files. Config file yo-rc.json is created in tmp, marking project root
  6. Now, create a subdirectory, tmp/subdir
  7. Cd into subdir
  8. Run Generator again
  9. Observe wrong behaviour, as seen above

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions