Last active
December 27, 2015 11:58
-
-
Save doug/7321954 to your computer and use it in GitHub Desktop.
Recursive watch Guardfile example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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