Skip to content

Commit

Permalink
debug: Test sub-functions in test V
Browse files Browse the repository at this point in the history
Some OS can only normalize a path if the associated file or folder exists
  • Loading branch information
MEO265 committed Dec 8, 2023
1 parent 1226e0c commit 88acd40
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/use_lintr.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ use_lintr <- function(path = ".", type = c("tidyverse", "full")) {
)
write.dcf(the_config, config_file, width = Inf)

# Some OS can only normalize a path if the associated file or folder exists, so the path needs to be re-normalized
config_file <- normalizePath(file.path(path, lintr_option("linter_file")), mustWork = TRUE, winslash = "/")
pkg_path <- normalizePath(path, mustWork = TRUE, winslash = "/")
# Check if config_file is in package i.e. lintr_option("linter_file") != "../.lintr"
pkg_path <- normalizePath(path, mustWork = FALSE, winslash = "/")
if (file.exists(file.path(path, "DESCRIPTION")) && startsWith(config_file, prefix = pkg_path)) {
# Skip a extra character for the leading `/`
rel_path <- substring(config_file, first = nchar(pkg_path) + 2L, last = nchar(config_file))
Expand Down

0 comments on commit 88acd40

Please sign in to comment.