Skip to content

mozey/watcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

watcher

CLI wrapper for fsnotify

You probably want to use one of the following tools instead

Quick start

Install

# Since Go 1.20.3 
# "'go get' is no longer supported outside a module"
go install github.com/mozey/watcher@latest

Print version

$GOPATH/bin/watcher -version

Watch files, only output changes

$GOPATH/bin/watcher -dir testdata

Watch files recursively, and print debug logs

APP_DEBUG=true $GOPATH/bin/watcher -r -dir testdata

Testing

Recursively watch for change in both ./testdata and ./testdata2

# APP_DIR env sets base dir
APP_DEBUG=true APP_DIR=$(pwd) go run ./main.go -r -dir testdata -dir testdata2
# Base dir set from flag
APP_DEBUG=true go run ./main.go -r -b $APP_DIR -dir testdata -dir testdata2

Using absolute path

cd ${PRO_PATH}/watcher # Base dir defaults to working dir
APP_DEBUG=true go run ./main.go -r \
    -dir testdata \
    -dir ${PRO_PATH}/watcher/testdata2

Example with filters

APP_DEBUG=true APP_DIR=$(pwd) go run ./main.go -r -dir testdata \
-include ".*.txt$" \
-include ".*.json$" \
-excludeDir ".*exclude.*" \
-exclude ".*\/d.txt$"

TODO See comments in main_test.go