Created
September 19, 2012 21:21
-
-
Save dill/3752343 to your computer and use it in GitHub Desktop.
watch a directory for changes to .Rmd (knitr+markdown files) and if any change, knit them. Best used with Marked by Brett Terpstra (set it to watch the .md files that knitr will generate).
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
# watch all .Rmd files in a directory, if any change, knit them | |
library(knitr) | |
# use watch from Hadley's testthat package | |
library(testthat) | |
watchr<-function(path){ | |
# the path supplied here can just be something like "./" | |
# taken from auto-test.r | |
knit_it<-function(added, deleted, modified) { | |
changed <- normalizePath(c(added, modified)) | |
for(a_file in changed){ | |
knit(a_file) | |
} | |
TRUE | |
} | |
watch(path,knit_it,".Rmd") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment