Created by: bmuenzenmeyer
close #7892 (closed)
Proactively append to .gitignore during generation instead relying on a try/catch
As #7892 (closed) illustrates, relying on the EEXISTS error is not reliable after the fs-extra@8.X upgrade. This fact was confirmed by the fs-extra team when I opened an an issue with them.
The solution is to check whether or not .gitignore exists in the current repo and proactively append gitignore to it, rather than rely on the try catch logic to sniff for EEXISTS / dest already exists errors from fs-extra
Testing
I attempted to test this:
- adding a directory to the monorepo,
foo - placing a
.gitignoreinto it with contents. - I commit that to avoid the git status porcelain check
- Run
yarn create-react-app foo --template typescript
This succeeds, but gives me warnings about not having a version that supports template. If I do not supply a template, the CLI tells me none was applied.
When I run this without the template arg, I get a reverse error message, stating no template was applied. Having maintained a fork for a long time, I know not to rely on the npm script create-react-app as gospel for a real generation. I also know that this new template functionality is still in progress - so I am guessing it's just a quick of this being a bit in-flight.
I think a better approach may be to add a check for this proper appending via CI, but I wanted to get this out here first. I'd also state that the code is pretty darn simple, mostly co-opted from the existing try / catch, and that I don't see any .gitignore coverage currently in the e2e tests. Perhaps a visual review is okay without a formal test - but I'll leave that to the maintainers to decide.