How to execute a command right before compiling?

My project contains a faulty library which contains some bad source files that causing error.

I want to execute a command such as
rm -r "./.pio/libdeps/ci/TTGO TWatch Library/src/libraries/TFT_eSPI"
to delete it before compiling.
What shouid I do?

The following command isn’t working because it is executed before downloading libraries.

build_flags = 
    ${common.build_flags}
    !rm -r "./.pio/libdeps/ci/TTGO TWatch Library/src/libraries/TFT_eSPI"