Skip to content

Commit a96d166

Browse files
committed
remove usethis and fs functions
1 parent a9e8be3 commit a96d166

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

DESCRIPTION

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ Imports:
3737
Suggests:
3838
bookdown,
3939
crayon,
40-
fs,
4140
httr (>= 1.2.1),
4241
jsonlite,
4342
mockery,
@@ -48,7 +47,6 @@ Suggests:
4847
testthat (>= 3.0.0),
4948
tibble,
5049
tufte,
51-
usethis,
5250
withr (>= 2.5.0)
5351
VignetteBuilder:
5452
knitr

R/use_lintr.R

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,31 @@ use_lintr <- function(path = ".", type = c("tidyverse", "full")) {
4545
write.dcf(the_config, config_file, width = Inf)
4646

4747
# If this is an R package and if available, add .lintr file to .Rbuildignore
48-
if (file.exists("DESCRIPTION")) {
48+
if (file.exists("DESCRIPTION") && file.exists(".Rbuildignore")) {
4949
try(
50-
usethis::use_build_ignore(fs::path_rel(config_file)),
50+
add_build_ignore(config_file),
5151
silent = TRUE
5252
)
5353
}
5454

5555
invisible(config_file)
5656
}
57+
58+
add_build_ignore <- function(path) {
59+
path_build_ignore <- ".Rbuildignore"
60+
existing_lines <- readLines(path_build_ignore, encoding = "UTF-8", warn = FALSE)
61+
62+
escape_path <- gsub("^\\./", "", path)
63+
escape_path <- gsub("\\.", "\\\\.", escape_path)
64+
escape_path <- gsub("/$", "", escape_path)
65+
escape_path <- paste0("^", escape_path, "$")
66+
67+
new_lines <- c(existing_lines, setdiff(escape_path, existing_lines))
68+
69+
con <- file(path_build_ignore, open = "wb", encoding = "utf-8")
70+
writeLines(enc2utf8(new_lines), con, useBytes = TRUE)
71+
72+
message("Add '", escape_path, "' to ", path_build_ignore)
73+
74+
invisible(NULL)
75+
}

0 commit comments

Comments
 (0)