komposable / komponent

An opinionated way of organizing front-end code in Ruby on Rails, based on components
http://komponent.io
MIT License
426 stars 31 forks source link

Make component generator idempotent #62

Closed Spone closed 6 years ago

Spone commented 6 years ago

I should be able to run the rails generate component button command several times with the same result. Currently, it duplicates the import in frontend/components/index.js

I think we just need to deduplicate the imports when we sort them here: https://github.com/komposable/komponent/blob/master/lib/generators/component/component_generator.rb#L173

florentferry commented 6 years ago

Yes, remove duplicates before rewriting it to file seems the only thing to do to make this possible.