Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix copy_quizzes to use quiz_dir #82

Merged
merged 1 commit into from
Sep 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions R/bookdown_to_leanpub.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,14 @@ copy_bib <- function(path = ".", output_dir = "manuscript") {
}
}

copy_quizzes <- function(path = "./quizzes", output_dir = "manuscript") {
path <- bookdown_path(path)
files <- list.files(path = path, full.names = TRUE, pattern = "^quiz")
copy_quizzes <- function(quiz_dir = "quizzes", output_dir = "manuscript") {
if (!dir.exists(quiz_dir)) {
stop(paste("The quiz directory specified by quiz_dir:", quiz_dir, "does not exist."))
}
quizzes <- list.files(path = quiz_dir, full.names = TRUE, pattern = "\\.md$")
if (length(files) > 0) {
file.copy(files, file.path(output_dir), overwrite = TRUE)
fs::file_copy(quizzes, file.path(output_dir, basename(quizzes)),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It copies over the files, ditches the directory. Is this what we want, @carriewright11 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think that makes sense

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes... good point about the directory...

overwrite = TRUE)
}
}

Expand Down Expand Up @@ -248,7 +251,7 @@ bookdown_to_leanpub <- function(path = ".",
message("Copying bib files")
}

copy_quizzes(path, output_dir = output_dir)
copy_quizzes(quiz_dir = quiz_dir, output_dir = output_dir)
if (verbose) {
message("Copying quiz files")
}
Expand Down