| library(sass) | library(sass) | ||||
| library(fs) | library(fs) | ||||
| library(purrr) | library(purrr) | ||||
| library(cliapp) | |||||
| render_sass <- function(file, output = NULL, outdir = "rsthemes") { | render_sass <- function(file, output = NULL, outdir = "rsthemes") { | ||||
| if (is.null(output)) { | if (is.null(output)) { | ||||
| path_ext(output) <- "rstheme" | path_ext(output) <- "rstheme" | ||||
| } | } | ||||
| output <- path(outdir, output) | output <- path(outdir, output) | ||||
| cli_alert_success("{path {path_file(file)}}") | |||||
| sass(sass_file(paste(file)), output = output) | sass(sass_file(paste(file)), output = output) | ||||
| } | } | ||||
| dir_create("rsthemes") | dir_create("rsthemes") | ||||
| cli_alert_info("Compiling themes...") | |||||
| dir_ls(regexp = "^[^_].+\\.scss") %>% | dir_ls(regexp = "^[^_].+\\.scss") %>% | ||||
| walk(render_sass) | walk(render_sass) | ||||
| cp_to_rstudio <- function(file) { | cp_to_rstudio <- function(file) { | ||||
| cli_alert("{path {path_file(file)}}") | |||||
| file_copy( | file_copy( | ||||
| file, | file, | ||||
| path_home_r(".R", "rstudio", "themes", path_file(file)), | path_home_r(".R", "rstudio", "themes", path_file(file)), | ||||
| ) | ) | ||||
| } | } | ||||
| cli_alert_info('Installing themes to {path {path_home_r(".R", "rstudio", "themes")}}') | |||||
| dir_ls("rsthemes", regexp = "\\.rstheme") %>% | dir_ls("rsthemes", regexp = "\\.rstheme") %>% | ||||
| walk(cp_to_rstudio) | walk(cp_to_rstudio) |