Open chiubaka opened 2 years ago
Just did a very, very quick test and am thinking this may actually still be achievable.
I had an inkling that the way I was passing options down to sub generators might be squashing some internals in a bad way. I've since changed this to only pass the answers down instead of the full options object.
A very quick test suggests to me that I can now read the README.md file in NodeModuleGenerator#install normally.
For example, the
NodeModuleGenerator
should be responsible for the NPM shield and theCircleCiGenerator
should be responsible for the CircleCI shield.This would be nice because it means that subgenerators are, themselves, completely self-contained. If I don't run the
CircleCiGenerator
, no other generator is going to see anything at all related to CircleCI. There are a few exceptions since we globally expect there to be both a README and a .gitignore file, but for the most part this model makes sense to me.I encountered some difficulty getting this to work properly. Specifically, I was finding that the
NodeModuleGenerator
would constantly fail to find theREADME.md
file that should have been created already by theReadmeGenerator
that it was composed with.Some logging did reveal that the
ReadmeGenerator#writing
method was being called before my attempts to write toREADME.md
(note, though, that by defaultNodeModuleGenerator#writing
appears to happen before its composed sub-generators, so I placed my write attempt inconflicts
orinstall
).I kept getting that
README.md
does not exist. Weirdly, doingthis.fs.exists("README.md")
would return true, butthis.fs.read("README.md")
would throw the error.I did some searching around in the Yeoman docs and in the underlying
mem-fs-editor
docs and found that this functionality should be working becausemem-fs-editor
seems like it should be checking its in-memory files before going to disc and because Yeoman claims to be sharing themem-fs-editor
instance across all subgenerators.Ultimately, I gave up on getting this to work and decided to move the shield generation into
ReadmeGenerator
, which I don't love.