Commit a16449d6 authored by Languillaume, Antoine's avatar Languillaume, Antoine
Browse files

Check if wd empty before setting project

parent a48d3cc6
......@@ -2,19 +2,50 @@
current_wd <- getwd()
current_files <- list.files(current_wd)
if(length(current_files) != 0){
message(paste0("Working directory is not empty. You might loose existing files.",
" \n",
"Are you sure you want to continue ?"))
answer <- readline("(Yes/No) \n")
valid_answer <- answer %in% c("Yes", "No")
while(valid_answer == FALSE) {
message("Answer can only be Yes or No:")
answer <- readline()
valid_answer <- answer %in% c("Yes", "No")
}
if(answer == "No"){
stop("Please back up your files or set up the project in another directory.",
call. = FALSE)
}
}
url_repo <- paste0("https://git.wageningenur.nl/langu001/PPS_data_management/-/archive/",
"refactor/PPS_data_management-refactor.zip")
download.file(url = url_repo,
destfile = file.path(current_wd, "project.zip"))
unzip("project.zip")
list_files <- list.files("./PPS_data_management-refactor/",
full.names = TRUE)
file.copy(from = list_files,
to = "./",
recursive = TRUE)
unlink(file.path(current_wd, "./PPS_data_management-refactor/"),
recursive = TRUE)
unlink(c("project.zip", "download_project.R", "README.md"))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment