jondot / hygen

The simple, fast, and scalable code generator that lives in your project.
http://www.hygen.io
MIT License
5.68k stars 256 forks source link

[Bug] `inject` fails silently when `after` or `before` match nothing #404

Open c-vetter opened 2 years ago

c-vetter commented 2 years ago

When after or before fail to match, the current behaviors are both surprising and different from each other:

Both cases are logged as inject giving the impression that all is well. These behaviors are problematic because in the before-case important code may go missing, and in the after-case the resulting file may be broken.

Both should actually leave the file alone and log as skipped so the developer is immediately informed instead of trying to run this potentially broken state in the assumption that the generator worked as expected.