Skip to content

Commit

Permalink
fix: set default value for argument name before using it
Browse files Browse the repository at this point in the history
the order needs a change at some places: first set a default value when name argument is missing, only then call check_name_length() to avoid errors of the type:

"argument "name" is missing, with no default"
  • Loading branch information
ilyaZar committed Jul 5, 2023
1 parent 89b04ab commit 71f341a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions R/use_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ use_external_file <- function(
open = FALSE,
dir_create = TRUE
) {
check_name_length(name)

if (missing(name)) {
name <- basename(url)
}

check_name_length(name)

old <- setwd(fs_path_abs(pkg))
on.exit(setwd(old))
Expand Down Expand Up @@ -266,14 +266,15 @@ use_internal_js_file <- function(
open = FALSE,
dir_create = TRUE
) {
check_name_length(name)
old <- setwd(fs_path_abs(pkg))
on.exit(setwd(old))

if (missing(name)) {
name <- basename(path)
}

check_name_length(name)

name <- file_path_sans_ext(name)
new_file <- sprintf("%s.js", name)

Expand Down Expand Up @@ -331,7 +332,6 @@ use_internal_css_file <- function(
open = FALSE,
dir_create = TRUE
) {
check_name_length(name)

old <- setwd(fs_path_abs(pkg))
on.exit(setwd(old))
Expand All @@ -340,6 +340,8 @@ use_internal_css_file <- function(
name <- basename(path)
}

check_name_length(name)

name <- file_path_sans_ext(name)
new_file <- sprintf("%s.css", name)

Expand Down

0 comments on commit 71f341a

Please sign in to comment.