From 281de4e27c8fb46b14915ec63281a8274c73006c Mon Sep 17 00:00:00 2001 From: IlyaZar Date: Wed, 5 Jul 2023 12:56:42 +0200 Subject: [PATCH] fix: set default value for argument name before using it 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" Refs: #1060 --- R/use_files.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R/use_files.R b/R/use_files.R index 1c322f5d..ed4667dd 100644 --- a/R/use_files.R +++ b/R/use_files.R @@ -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)) @@ -266,7 +266,6 @@ use_internal_js_file <- function( open = FALSE, dir_create = TRUE ) { - check_name_length(name) old <- setwd(fs_path_abs(pkg)) on.exit(setwd(old)) @@ -274,6 +273,8 @@ use_internal_js_file <- function( name <- basename(path) } + check_name_length(name) + name <- file_path_sans_ext(name) new_file <- sprintf("%s.js", name) @@ -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)) @@ -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)