A lightweight, real-time file system watcher and static HTTP file server. It triggers custom user commands upon detecting changes in directories or files. It is written in Go and has 0 dependencies.
While developing my portfolio's API, I continuously restarted my portfolio server to reflect my code changes. Also, as I build my Portfolio WebApp for testing I need to install an HTTP server or configure my laptop's Nginx to serve the html file created after the build process. So, I've built this CLI tool to automate these two most common tasks.
Currently filepatrol
is only available if you have Go installed in your system APT, AUR, and Brew versions are coming soon.
To install Go on your system follow the official instructions. After installing Go on your system follow these following instructions to make sure your system is able to use any installed go packages from it's terminal (bash/zsh/fish).
If you are using bash
echo 'export GOPATH=$HOME/go' >> ~/.bashrc
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
echo 'export PATH=$PATH:$GOBIN' >> ~/.bashrc
source ~/.bashrc
If you are using bash
echo 'export GOPATH=$HOME/go' >> ~/.zsh
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.zsh
echo 'export PATH=$PATH:$GOBIN' >> ~/.zsh
source ~/.zshrc
go install github.com/sifatulrabbi/filepatrol@latest
This CLI can watch files of a selected directory and execute one or many valid terminal commands. If the command/s fail it will print out the errors and gracefully exit. This file watcher stores the watching files list in the memory using a Map.
Basic syntax
filepatrol --path [target dir path] --cmd [the command/s it should run]
Example 1: It is better to wrap the command/s with ''
or ""
filepatrol --path ./sifatul-api --cmd 'make run'
Example 2: If it's a valid terminal command then it will execute
filepatrol --cmd "jq '.items[-1]' ./logs/errors.json ; jq '. | length' ./logs/errors.json" --path ./logs
Basic syntax
filepatrol --exec http --path [target dir path]
# Example
filepatrol --exec http --path ./portfolio/build