|
|
|
|
|
|
|
|
library(purrr) |
|
|
library(purrr) |
|
|
library(cliapp) |
|
|
library(cliapp) |
|
|
|
|
|
|
|
|
render_sass <- function(file, output = NULL, outdir = "dist") { |
|
|
|
|
|
if (is.null(output)) { |
|
|
|
|
|
output <- path_file(file) |
|
|
|
|
|
path_ext(output) <- "rstheme" |
|
|
|
|
|
} |
|
|
|
|
|
output <- path(outdir, output) |
|
|
|
|
|
cli_alert_success("{path {path_rel(file, getwd())}}") |
|
|
|
|
|
sass(sass_file(paste(file)), output = output) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
source("R/make_functions.R") |
|
|
|
|
|
|
|
|
dir_create("dist") |
|
|
dir_create("dist") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dir_ls("src", regexp = "^[^_].+\\.scss") %>% |
|
|
dir_ls("src", regexp = "^[^_].+\\.scss") %>% |
|
|
walk(render_sass) |
|
|
walk(render_sass) |
|
|
|
|
|
|
|
|
get_theme_name <- function(file) { |
|
|
|
|
|
x <- readLines(file, warn = FALSE) |
|
|
|
|
|
x <- grep("rs-theme-name", x, value = TRUE) |
|
|
|
|
|
if (!length(x)) return("") |
|
|
|
|
|
x <- sub("^\\s*/\\*\\s*rs-theme-name:\\s", "", x) |
|
|
|
|
|
x <- sub("\\s*\\*/\\s*$", "", x) |
|
|
|
|
|
x |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
cp_to_rstudio <- function(file) { |
|
|
|
|
|
cli_alert("{arg \"{get_theme_name(file)}\"}") |
|
|
|
|
|
file_copy( |
|
|
|
|
|
file, |
|
|
|
|
|
path_home_r(".R", "rstudio", "themes", path_file(file)), |
|
|
|
|
|
overwrite = TRUE |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
cli_alert_info('Installing themes to {path {path_home_r(".R", "rstudio", "themes")}}') |
|
|
cli_alert_info('Installing themes to {path {path_home_r(".R", "rstudio", "themes")}}') |
|
|
dir_ls("dist", regexp = "\\.rstheme") %>% |
|
|
dir_ls("dist", regexp = "\\.rstheme") %>% |
|
|
walk(cp_to_rstudio) |
|
|
walk(cp_to_rstudio) |