From bfd92410cd15f541085ec29dd756f79c3ffa1d10 Mon Sep 17 00:00:00 2001 From: Jeroen Ooms Date: Mon, 4 Mar 2024 13:18:51 +0000 Subject: [PATCH] Support custom wordlist via SPELLING_WORDLIST variable Closes #80 --- R/wordlist.R | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/R/wordlist.R b/R/wordlist.R index c929643..ed4dcd0 100644 --- a/R/wordlist.R +++ b/R/wordlist.R @@ -53,11 +53,18 @@ update_wordlist <- function(pkg = ".", vignettes = TRUE, confirm = TRUE){ get_wordlist <- function(pkg = "."){ pkg <- as_package(pkg) wordfile <- get_wordfile(pkg$path) - out <- if(file.exists(wordfile)) - unlist(strsplit(readLines(wordfile, warn = FALSE, encoding = "UTF-8"), " ", fixed = TRUE)) - as.character(out) + pkg_wordlist <- if(file.exists(wordfile)) + read_wordfile(wordfile) + global_wordfile <- Sys.getenv('SPELLING_WORDLIST') + global_wordlist <- if(nchar(global_wordfile) && file.exists(global_wordfile)) + read_wordfile(global_wordfile) + as.character(c(pkg_wordlist, global_wordlist)) } get_wordfile <- function(path){ normalizePath(file.path(path, "inst/WORDLIST"), mustWork = FALSE) } + +read_wordfile <- function(wordfile){ + unlist(strsplit(readLines(wordfile, warn = FALSE, encoding = "UTF-8"), " ", fixed = TRUE)) +}