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).
# 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