Skip to content

Instantly share code, notes, and snippets.

@doug
Last active December 27, 2015 11:58
Show Gist options
  • Save doug/7321954 to your computer and use it in GitHub Desktop.
Save doug/7321954 to your computer and use it in GitHub Desktop.
Recursive watch Guardfile example
#!/usr/bin/env python
# AppEngine Guardfile
# More info at https://github.com/lepture/python-livereload
from livereload.task import Task
from livereload.compiler import shell
def recursive_watch(directory, filetypes, *args, **kwargs):
import os
for root, dirs, files in os.walk(directory):
if filetypes:
towatch = set()
for filetype in filetypes:
for f in files:
if filetype in f:
towatch.add(filetype)
for filetype in towatch:
Task.add(os.path.join(root,"*.{}".format(filetype)), *args, **kwargs)
else:
Task.add(os.path.join(root, "*"), *args, **kwargs)
recursive_watch(".", ["go", "html", "js", "yaml"])
Task.add("static/*.scss", shell("sass --update static"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment