Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
feature: add unless exists option to add operation #27
Added a feature to the add operation to only execute unless the file already exists.
Motivation for this feature
When generating code it is necessary to not only generate the new code but also use injections to "register" it in other parts of the application. This works fine by using the inject feature.
Its easy to build a generator that creates a new "controllerB" in my_module/controllers and its test int my_module/tests and also inject the controllerB.spec.js registration in the suite.js.
But maybe the my_module doesn't have tests and a suite.js file yet. I would need to create a completely new generator just so that i have one that also generates the suite.js.
Therefore I could use a unless_exists to only run a template for scaffolding the suite.js when it doesn't exist, but also reuse all the other templates no matter if its a brand new (aka empty) module or I want to make an addition to an existing module.
The docs are missing yet. I would write a doc part for it when you are fine with the feature and its not against the project goals.
Awesome idea, and clean implementation, thanks!
I only had one note here but otherwise I'm ready to merge