Fix --cache set only if with --write or no-different (#13016)
* Fixed typo
* Return early if file does not exist
* Added tests for cache
* Added `mockWriteFileErrors` option to run helper
* Added tests for write error
* Remove files with differences from cache
* Add `getCliArguments` utility function
Refactor
* Fix lint
* Revert "Fix lint"
This reverts commit 18be64b7c42cd669496d59ff64bd534b8e03c3df.
* Revert "Add `getCliArguments` utility function"
This reverts commit d653fe10a92390102ae97cb43b2efcbb5c3c9140.
* Refactor with `cliArguments` variable
Co-authored-by: Sosuke Suzuki <sosuke.suzuki@dr-ubie.com>