Skip to content

Commit

Permalink
Implement using @naupaka 's suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
mawds committed Jan 30, 2018
1 parent e7b99da commit 682e775
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions bin/generate_md_episodes.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@ generate_md_episodes <- function() {
}, src_rmd, dest_md)

# Read the generated md files and add comments advising not to edit them
sapply(dest_md, function(y) {
con = file(y)
vapply(dest_md, function(y) {
con <- file(y)
mdfile <- readLines(con)
if (mdfile[1] != "---")
stop("Input file does not have a valid header")
mdfile <- append(mdfile, "# Please do not edit this file directly; it is auto generated.", after = 1)
mdfile <- append(mdfile, paste("# Instead, please edit",
basename(y), "in _episodes_rmd/"), after = 2)
writeLines(mdfile, con)
})

mdfile <- append(mdfile, "# Please do not edit this file directly; it is auto generated.", after = 1)
mdfile <- append(mdfile, paste("# Instead, please edit",
basename(y), "in _episodes_rmd/"), after = 2)
writeLines(mdfile, con)
close(con)
return(paste("Warning added to YAML header of", y))
},
character(1))
}

generate_md_episodes()

0 comments on commit 682e775

Please sign in to comment.