Watching for arbitrary file changes using Bacon
To compile, test, or run Rust code automatically when a file changes, I use cargo watch -c -x run.
But in a healthy decision for the Cargo Watch author, the project is over: “It's time to let it go. Use Bacon. Remember Cargo Watch.”
The defaults for Bacon and Cargo Watch are different. I noticed this today when expecting a file to run when I changed any file in my project. The trick is to add anything unusual to a configuration file.
Generate a config file with:
bacon --init
Then modify the bacon.toml file to read:
[jobs.run]
command = ["cargo", "run", "--color", "always"]
need_stdout = true
allow_warnings = true
watch = ["me.too"]
…or similar, to watch a specific list of files (or “me.too” in this example).