Skip to content

Commit

Permalink
fixed bug in uninstall_all_courses
Browse files Browse the repository at this point in the history
  • Loading branch information
seankross committed Nov 15, 2014
1 parent a8e64f1 commit e1796bc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions R/install_course.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ uninstall_course <- function(course_name){
#' @family InstallCourses
uninstall_all_courses <- function(){
path <- file.path(system.file(package = "swirl"), "Courses")
if(file.exists(file.path(path, "suggested_courses.yaml"))){
yaml_exists <- file.exists(file.path(path, "suggested_courses.yaml"))
if(yaml_exists){
temp_file <- tempfile()
file.copy(file.path(path, "suggested_courses.yaml"), temp_file)
}
Expand All @@ -225,8 +226,12 @@ uninstall_all_courses <- function(){
}

dir.create(path, showWarnings = FALSE)
file.copy(temp_file, path)
file.rename(list.files(path, full.names = TRUE), file.path(path, "suggested_courses.yaml"))

if(yaml_exists){
file.copy(temp_file, path)
file.rename(list.files(path, full.names = TRUE), file.path(path, "suggested_courses.yaml"))
}

invisible()
}

Expand Down

0 comments on commit e1796bc

Please sign in to comment.