Monitoring Directories for File Changes using Watchdog

I was working recently on writing Python code using TDD. So every time I change code I wanted to run command that will test my code if it pass unit tests. In order to do that I needed some service/app that will monitor for file changes, and if it changes execute my batch file that runs unit tests. There are different option on how to do it, one of the option is to use Gulp, however I decided to check if there are any alternative options besides Gulp, and indeed I found alternative solution — watchdog

Here is what documentation says about watchdog

Python API and shell utilities to monitor file system events.

This is Python application so you have to have Python runtime installed, and it runs on Python 2.6 and above.

After installing watchdog

 pip install watchdog

I was able to run watchmedo utility to monitor my files and run batch file in case if any of my *.py files are changed

watchmedo shell-command --patterns="*.py" --command="run.bat" --ignore-directories

You can get more help on watchmedo by

watchmedo shell-command --help