treefmt icon indicating copy to clipboard operation
treefmt copied to clipboard

Update cache on partial failure

Open mloughran opened this issue 2 years ago • 0 comments

Currently if a treefmt run completes but one of the formatters exits with an error, the cache does not get updated, and subsequent treefmt runs will therefore have more work to do than necessary.

For example, in this example, the elm cache could have been updated:

% treefmt
[INFO]: #elm: 2 files processed in 32.26ms
[INFO]: Error using formatter #ruby:
• [STDOUT]:

• [STDERR]:
/snip/test.rb:3 syntax error, unexpected `end', expecting end-of-input

[ERR]: #ruby's formatter failed: exit status 1

If this behaviour is necessary for some reason, I think this should be logged, e.g.:

[WARN]: Cache not updated since 1 or more formatters failed

This is particularly an issue on first run or if treefmt has not been run in a while (since there might be a lot of work to do).

mloughran avatar May 03 '22 13:05 mloughran