DefactoSoftware / ex_css_modules

CSS Modules for Elixir
MIT License
18 stars 1 forks source link

Fix error with empty style definitions json file #113

Closed EasterPeanut closed 1 year ago

EasterPeanut commented 1 year ago

An artifact in our own codebase could sometimes cause empty style definitions json files. This will fail compilation of ex_css_modules because decoding an empty string is not working.

To capture this edge case, let's check if the file is empty before trying to decode OR generate the json file through a task.

codecov-commenter commented 1 year ago

Codecov Report

Merging #113 (63a4140) into master (425bb3a) will increase coverage by 1.58%. The diff coverage is 86.66%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##           master     #113      +/-   ##
==========================================
+ Coverage   91.89%   93.47%   +1.58%     
==========================================
  Files           2        2              
  Lines          37       46       +9     
==========================================
+ Hits           34       43       +9     
  Misses          3        3              
Files Coverage Δ
lib/ex_css_modules/view.ex 100.00% <ø> (ø)
lib/ex_css_modules/ex_css_modules.ex 92.50% <86.66%> (+2.17%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

zwippie commented 1 year ago

Tested in detroit with this branch. Added build_stylesheet_definitions_json_task option in web.ex. Deleted a random style.css json file. Results was a (UndefinedFunctionError) function Mix.Tasks.GenerateMissingJson.run/1 is undefined but I guess that task is on its way.

Nice!

EasterPeanut commented 1 year ago

Tested in detroit with this branch. Added build_stylesheet_definitions_json_task option in web.ex. Deleted a random style.css json file. Results was a (UndefinedFunctionError) function Mix.Tasks.GenerateMissingJson.run/1 is undefined but I guess that task is on its way.

Nice!

Yes! That will be done in https://github.com/DefactoSoftware/detroit/pull/13193 :D