Closed krambono closed 4 years ago
@knona I think I am going to write unit tests for the main code of my library so I can make sure I have the correct validation in the right place. So I will work on this when I can and hopefully I will have it complete next week. This is a nice to have and not a blocker from using the new command line feature.
@codeBelt Yes you're right, it's a good idea.
I pushed 2 new commits. One which fix a bug: we had to use the option --overwrite
in all cases even if the files were not created before.
The 2nd fix the bug which we talked about earlier.
I let you decide what behavior you want and therefore if you want to revert my last commit.
About the tests, I can describe some tests (.i.e orignal state and result expected) if that can help you.
@knona If you have the time you can describe some tests otherwise don't worry about.
You can see commit by commit what I did. The main bug was when stringReplacers was not defined. slots length was equals to 0 and stringReplacers to undefined. Therefore the test
stringReplacers?.length === slots.length
was false.I added too try/catch blocks to catch the errors and display them. I don't think it's really "elegant" but we must do that I guess.
An other "bug" could happen when you define two times the same stringReplacer as argument. Example :
node generate.js vue-vuex-store __store__=firstValue __model__=myModel __store__=secondValue
Here, our code will throw an error because the length of arguments is not equal to the length of stringReplacers. We could imagine that we take the last value passed as argument for each stringReplacer. Therefore in this case, there would be no problems. I don't know what behavior you want for this case.