Skip to content

Instantly share code, notes, and snippets.

@schnittchen
Forked from splattael/touch
Created April 10, 2017 11:18
Show Gist options
  • Save schnittchen/aed058c72e8d85db2123c2addfb4ca03 to your computer and use it in GitHub Desktop.
Save schnittchen/aed058c72e8d85db2123c2addfb4ca03 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Touches changed files in order to make it work
# when filesystem changes are not properly detected
# by development mode code reloading.
#
# Usage: bin/touch_changed [<sleep every>]
EVERY=${1:-1}
RELOAD="/tmp/reload"
DIRS="web lib"
# Initial touch
touch $RELOAD
find_changed() {
find $DIRS -type f -newer $RELOAD | grep -E -v '\.sw.$'
}
while :; do
files=$(find_changed)
if [ "$files" != "" ]; then
echo "Changed: $files"
touch $RELOAD
touch -r $RELOAD $files
fi
sleep $EVERY
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment