Skip to content

Commit

Permalink
remove usethis and fs functions
Browse files Browse the repository at this point in the history
  • Loading branch information
eitsupi committed Jan 9, 2023
1 parent a9e8be3 commit efe56d1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ Imports:
Suggests:
bookdown,
crayon,
fs,
httr (>= 1.2.1),
jsonlite,
mockery,
Expand All @@ -48,8 +47,8 @@ Suggests:
testthat (>= 3.0.0),
tibble,
tufte,
usethis,
withr (>= 2.5.0)
withr (>= 2.5.0),
xfun
VignetteBuilder:
knitr
Config/Needs/website: tidyverse/tidytemplate
Expand Down
19 changes: 17 additions & 2 deletions R/use_lintr.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,27 @@ use_lintr <- function(path = ".", type = c("tidyverse", "full")) {
write.dcf(the_config, config_file, width = Inf)

# If this is an R package and if available, add .lintr file to .Rbuildignore
if (file.exists("DESCRIPTION")) {
if (file.exists("DESCRIPTION") && file.exists(".Rbuildignore")) {
try(
usethis::use_build_ignore(fs::path_rel(config_file)),
add_build_ignore(config_file),
silent = TRUE
)
}

invisible(config_file)
}

add_build_ignore <- function(path) {
path_build_ignore <- file.path(".", ".Rbuildignore")
existing_lines <- xfun::read_utf8(path_build_ignore)

escape_path <- rex::rex(start, rex::re_substitutes(path, list(start, "./") %or% list("/", end), ""), end)

new_lines <- c(existing_lines, setdiff(escape_path, existing_lines))

xfun::write_utf8(new_lines, path_build_ignore)

message("Add '", escape_path, "' to ", path_build_ignore)

invisible(NULL)
}

0 comments on commit efe56d1

Please sign in to comment.