@@ -52,7 +52,11 @@ spell_check_bookdown <- function(path = ".", lang = NULL, use_wordlist = TRUE){
5252 author <- if (length(pkg [[' authors@r' ]])){
5353 parse_r_field(pkg [[' authors@r' ]])
5454 } else {
55- strsplit(pkg [[' author' ]], " " , fixed = TRUE )[[1 ]]
55+ if (" author" %in% names(pkg )) {
56+ strsplit(pkg [[' author' ]], " " , fixed = TRUE )[[1 ]]
57+ } else {
58+ author <- NULL
59+ }
5660 }
5761
5862 meta <- c(pkg $ package , author )
@@ -65,23 +69,28 @@ spell_check_bookdown <- function(path = ".", lang = NULL, use_wordlist = TRUE){
6569 dict <- hunspell :: dictionary(lang , add_words = sort(ignore ))
6670
6771 # Where to check for rmd/md files
68- bookdown_files <- list.files(file.path(pkg $ path ), pattern = " \\ .r?md $" ,
72+ bookdown_files <- list.files(file.path(path ), pattern = " \\ .rmd $" ,
6973 ignore.case = TRUE , full.names = TRUE , recursive = TRUE )
70- root_files <- list.files(pkg $ path , pattern = " (readme|news|changes|index ).r?md" ,
74+ root_files <- list.files(file. path( path ) , pattern = " (readme|news|changes).r?md" ,
7175 ignore.case = TRUE , full.names = TRUE )
7276
7377 # Markdown files
74- md_files <- normalizePath(c(root_files , bookdown_files ))
75- md_lines <- lapply(sort( md_files ) , spell_check_file_md , dict = dict )
78+ md_files <- sort( normalizePath(c(root_files , bookdown_files ) ))
79+ md_lines <- lapply(md_files , spell_check_file_md , dict = dict )
7680
7781 all_sources <- md_files
7882 all_lines <- md_lines
7983
8084 # Check 'DESCRIPTION' fields
8185 if (file.exists(file.path(path , " DESCRIPTION" ))){
8286 pkg_fields <- c(" title" , " description" )
87+ pkg <- as_package(path )
8388 pkg_lines <- lapply(pkg_fields , function (x ){
84- spell_check_file_text(textConnection(pkg [[x ]]), dict = dict )
89+ if (x %in% names(pkg )) {
90+ spell_check_file_text(textConnection(pkg [[x ]]), dict = dict )
91+ } else {
92+ spell_check_file_text(textConnection(" " ), dict = dict )
93+ }
8594 })
8695
8796 all_sources <- c(all_sources , pkg_fields )
0 commit comments