Skip to content

Commit 33d2284

Browse files
committed
Explicitly lowercase the extension in use_logo()
Fixes #1999
1 parent fdeaa73 commit 33d2284

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

R/logo.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020
use_logo <- function(img, geometry = "240x278", retina = TRUE) {
2121
check_is_package("use_logo()")
2222

23-
logo_path <- proj_path("man", "figures", "logo", ext = path_ext(img))
23+
ext <- tolower(path_ext(img))
24+
logo_path <- proj_path("man", "figures", "logo", ext = ext)
2425
create_directory(path_dir(logo_path))
2526
if (!can_overwrite(logo_path)) {
2627
return(invisible(FALSE))
2728
}
2829

29-
if (path_ext(img) == "svg") {
30+
if (ext == "svg") {
3031
logo_path <- path("man", "figures", "logo.svg")
3132
file_copy(img, proj_path(logo_path), overwrite = TRUE)
3233
ui_bullets(c("v" = "Copied {.path {pth(img)}} to {.path {logo_path}}."))

tests/testthat/_snaps/logo.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,13 @@
88
[ ] Add logo to 'README.md' with the following html:
99
# {TESTPKG} <img src="man/figures/logo.png" align="right" height="90" alt="" />
1010

11+
# use_logo() writes a file in lowercase and it knows that
12+
13+
Code
14+
use_logo("LoGo.PNG")
15+
Message
16+
v Creating 'man/figures/'.
17+
v Resized 'LoGo.PNG' to 240x278.
18+
[ ] Add logo to your README with the following html:
19+
# {TESTPKG} <img src="man/figures/logo.png" align="right" height="90" alt="" />
20+

tests/testthat/test-logo.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,16 @@ test_that("use_logo() shows a clickable path with README", {
1717
withr::local_options(usethis.quiet = FALSE)
1818
expect_snapshot(use_logo("logo.png"), transform = scrub_testpkg)
1919
})
20+
21+
# https://github.com/r-lib/usethis/issues/1999
22+
test_that("use_logo() writes a file in lowercase and it knows that", {
23+
skip_if_not_installed("magick")
24+
skip_on_os("solaris")
25+
26+
create_local_package()
27+
img <- magick::image_write(magick::image_read("logo:"), "LoGo.PNG")
28+
29+
withr::local_options(list(usethis.quiet = FALSE))
30+
expect_snapshot(use_logo("LoGo.PNG"), transform = scrub_testpkg)
31+
expect_proj_file("man", "figures", "logo.png")
32+
})

0 commit comments

Comments
 (0)