Skip to content

Commit

Permalink
Allow use of a different github repo as mirror for swirledev.
Browse files Browse the repository at this point in the history
  • Loading branch information
elinw committed Nov 13, 2016
1 parent 7325dcd commit 0225b15
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions R/install_course.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ install_from_swirl <- function(course_name, dev = FALSE, mirror = "github"){
if(!is.logical(dev)) {
stop(s()%N%"Argument 'dev' must be either TRUE or FALSE!")
}
if(!(mirror == "github" || mirror == "bitbucket")){
if(!(mirror == "github" || mirror == "bitbucket" || substr(mirror, 1, 7) == "github/")){
stop(s()%N%"Please enter a valid name for a mirror. ('github' or 'bitbucket')")
}

Expand All @@ -144,14 +144,15 @@ install_from_swirl <- function(course_name, dev = FALSE, mirror = "github"){
if(mirror != "github"){
stop(s()%N%"To access swirl courses in development on Bitbucket go to https://bitbucket.org/swirldevmirror/swirl_misc")
}
url <- "http://github.com/swirldev/swirl_misc/zipball/master"
} else {
if(mirror == "bitbucket"){
url <- "http://github.com/swirldev/swirl_misc/zipball/master"
} else if(mirror == "bitbucket"){
url <- "https://bitbucket.org/swirldevmirror/swirl_courses/get/HEAD.zip"
} else {
} else if(mirror == "github") {
url <- "http://github.com/swirldev/swirl_courses/zipball/master"
} else {
url <- paste0("http://github.com/", substr(mirror, 8, nchar(mirror)), "/swirl_courses/zipball/master")
}
}


# Send GET request
response <- GET(url, progress())
Expand Down Expand Up @@ -315,7 +316,6 @@ uninstall_all_courses <- function(force = FALSE){
} else {
stop(s()%N%"Uninstall failed.")
}

} else {
message("No courses were uninstalled.")
return()
Expand All @@ -327,7 +327,6 @@ uninstall_all_courses <- function(force = FALSE){
} else {
stop(s()%N%"Uninstall failed.")
}

}
} else {
stop(s()%N%"No courses found!")
Expand Down

0 comments on commit 0225b15

Please sign in to comment.