Skip to content

Conversation

@EasterPeanut
Copy link
Collaborator

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.

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
Copy link

codecov-commenter commented Oct 26, 2023

Codecov Report

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

❗ 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%) ⬆️

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

Raise a compile error with custom message if the JSON file is empty or
absent, explaining what to do to be able to compile again.
@EasterPeanut EasterPeanut force-pushed the pien/check-file-empty branch from ddfed67 to c626d84 Compare October 26, 2023 14:05
EasterPeanut and others added 2 commits October 26, 2023 16:33
It should check for the json to be empty, not the stylesheet. (Stylesheet was also empty, that's why the test would pass.)

Co-authored-by: Matthijs Kuiper <info@matthijskuiper.nl>
If the task does not exist, a compilation error will be thrown.
@zwippie
Copy link

zwippie commented Oct 26, 2023

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
Copy link
Collaborator Author

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

@EasterPeanut EasterPeanut merged commit 9ed26d1 into master Oct 26, 2023
@sn3p sn3p deleted the pien/check-file-empty branch October 31, 2023 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants