Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Forked from dill/watchr.R
Created January 4, 2013 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramnathv/4455678 to your computer and use it in GitHub Desktop.
Save ramnathv/4455678 to your computer and use it in GitHub Desktop.
# 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