Skip to content

Commit

Permalink
chore: Make rule file an argument rather than guessing
Browse files Browse the repository at this point in the history
  • Loading branch information
gadenbuie committed Jun 17, 2023
1 parent 248109e commit cfd03d2
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tools/download_preset_fonts.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ extract_first_group <- function(x, pattern) {
na.omit(sapply(matches, "[", 2))
}

download_and_copy_fonts <- function(theme) {
theme_file_choices <- paste0(c("_bootswatch", "_rules"), ".scss")
theme_files <- file.path(theme, theme_file_choices)
theme_file <- theme_files[file.exists(theme_files)][1]
download_and_copy_fonts <- function(theme, rule_file = "_bootswatch.scss") {
theme_file <- file.path(theme, rule_file)

if (!length(theme_file)) {
stop("Couldn't find a theme file in ", theme)
if (!file.exists(theme_file)) {
stop("Couldn't find '", rule_file, "' in ", theme)
}

theme_scss <- readLines(theme_file)
Expand Down Expand Up @@ -84,4 +82,4 @@ lapply(themes5, download_and_copy_fonts)
lapply(themes4, download_and_copy_fonts)
lapply(themes3, download_and_copy_fonts)

lapply(builtin5, download_and_copy_fonts)
lapply(builtin5, download_and_copy_fonts, rule_file = "_rules.scss")

0 comments on commit cfd03d2

Please sign in to comment.