render_sass <- function(file, output = NULL, outdir = "dist") { if (is.null(output)) { output <- fs::path_file(file) fs::path_ext(output) <- "rstheme" } output <- fs::path(outdir, output) cliapp::cli_alert_success("{path {fs::path_rel(file, getwd())}}") sass::sass(sass::sass_file(paste(file)), output = output) } 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) { cliapp::cli_alert("{arg \"{get_theme_name(file)}\"}") fs::file_copy( file, fs::path_home_r(".R", "rstudio", "themes", fs::path_file(file)), overwrite = TRUE ) }