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
- 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
initialise function as follows
_initialize() {
const defaults: Config = {
// Some defaults here
}
this.config.defaults(defaults)
}
- 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
- 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 file yo-rc.json is created in tmp, marking project root
- Now, create a subdirectory,
tmp/subdir
- Cd into
subdir
- Run Generator again
- Observe wrong behaviour, as seen above
Type of issue: Bug
My environment
MacOs 11.1314.16.1(runnode --versionin your terminal)6.14.12(runnpm --versionin your terminal)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 ayo-rc.jsonitself.Current behavior
tmp/files, the following file structure occursSteps to reproduce the behavior
initialisefunction as follows_initialisein theinitializingcontext. Generators create files either withthis.destinationRootor any configuration option in the confignpm linktmptmptmp/files. Config fileyo-rc.jsonis created intmp, marking project roottmp/subdirsubdir