-
-
Notifications
You must be signed in to change notification settings - Fork 302
Open
Description
Type of issue: Bug
My environment
- OS version/details:
MacOs 11.13 - Node version:
14.16.1(runnode --versionin your terminal) - npm version:
6.14.12(runnpm --versionin your terminal) - Version of yo :
4.0.0(runyo --versionin 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
- 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
- Set up simple project
- Create a "new" BaseGenerator, which all other generators extend from
- Write an
initialisefunction as follows
_initialize() {
const defaults: Config = {
// Some defaults here
}
this.config.defaults(defaults)
}
- In each Generator or Subgenerator, call
_initialisein theinitializingcontext. Generators create files either withthis.destinationRootor any configuration option in the config - Setup Generator with
npm link - Create a directory, we'll call it
tmp - Run generator in
tmp - Observe it working as intended. Files are created in
tmp/files. Config fileyo-rc.jsonis created intmp, marking project root - Now, create a subdirectory,
tmp/subdir - Cd into
subdir - Run Generator again
- Observe wrong behaviour, as seen above