~showy_fence


#87 In-place formatting empties out target files on any error 6 months ago

Ticket created by ~showy_fence on ~lattis/muon

Easiest way to reproduce is to try to use a non-existing config file path:

muon fmt -i -c /file/that/does/not/exist meson.build.

However, this also happens if there is an error in the configuration file, or there was an error while parsing meson.build, etc.

This happens because target file path is opened for writing before calling fmt(). I think the best way to fix this would be to instead write to a file called $target_file.$pid.tmp or something along the lines, and then rename it $target_value essentially overwriting the fie.