#' @export
remove <- function(repo) {
invisible(lapply(repo, remove_helper))
}
remove_helper <- function(repo, package) {
box::use(
jsonlite[write_json],
cli[cli_h1, cli_alert, cli_alert_warning, cli_alert_success],
glue[glue],
. / util[get_module_list],
fs[dir_delete],
here[here]
)
input <- as.list(unlist(strsplit(repo, "[/@]")))
package <- get_module_list()
if (any(unlist(input[2]) %in% package$modules$moduleName | unlist(input[1]) %in% package$modules$author)) {
package$modules <- package$modules[which(package$modules$moduleName != unlist(input[2]) | package$modules$author != unlist(input[1])), ]
cli_alert(
glue("'{input[1]}/{input[2]}' found in package.json")
)
write_json(package, "package.json", auto_unbox = TRUE, pretty = TRUE)
# * TODO fix this for global directories
dir_delete(glue("{here()}/modules/{input[2]}"))
cli_alert_success(
glue("'{input[2]}' removed.")
)
} else {
cli_alert_warning(
"Package.json does not contain {input[1]}/{input[2]}."
)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.