[mirror] Opinionated R package quickstart
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Try to format using air and jarl near completion

VisruthSK aa4c38f8 6dcf0359

+54 -1
+37
R/bootstrapper.R
··· 115 115 configure_dependabot() 116 116 } 117 117 118 + try_air_jarl_format() 118 119 usethis::use_tidy_description() 119 120 invisible(NULL) 120 121 } 121 122 122 123 # Helpers --------------------------------------------------------------------- 124 + 125 + #' Try Air/Jarl Formatting 126 + #' 127 + #' Attempts to run `air format .` and `jarl check . --fix --allow-dirty`. 128 + #' Errors and warnings are ignored so setup can continue if tools are unavailable. 129 + #' 130 + #' @return Invisibly returns a named logical vector indicating whether each 131 + #' check succeeded. 132 + #' @keywords internal 133 + #' @noRd 134 + try_air_jarl_format <- function() { 135 + air <- suppressWarnings( 136 + tryCatch( 137 + { 138 + system2("air", c("format", "."), stdout = FALSE, stderr = FALSE) 139 + TRUE 140 + }, 141 + error = function(...) FALSE 142 + ) 143 + ) 144 + jarl <- suppressWarnings( 145 + tryCatch( 146 + { 147 + system2( 148 + "jarl", 149 + c("check", ".", "--fix", "--allow-dirty"), 150 + stdout = FALSE, 151 + stderr = FALSE 152 + ) 153 + TRUE 154 + }, 155 + error = function(...) FALSE 156 + ) 157 + ) 158 + invisible(c(air = air, jarl = jarl)) 159 + } 123 160 124 161 #' Configure GitHub Actions Defaults 125 162 #'
+17 -1
tests/testthat/test-bootstrapper.R
··· 86 86 }) 87 87 88 88 test_that("pkg_setup runs expected top-level calls and setup sections", { 89 - calls <- list(actions = character(), sections = character(), replaced = FALSE) 89 + calls <- list( 90 + actions = character(), 91 + sections = character(), 92 + replaced = FALSE, 93 + formatted = FALSE 94 + ) 90 95 91 96 testthat::local_mocked_bindings( 92 97 use_testthat = function() { ··· 121 126 expect_true(fixed) 122 127 NULL 123 128 }, 129 + try_air_jarl_format = function() { 130 + calls$formatted <<- TRUE 131 + NULL 132 + }, 124 133 .package = "bootstrapper" 125 134 ) 126 135 ··· 132 141 expect_true("tidy_description" %in% calls$actions) 133 142 expect_identical(calls$sections, c("gha", "dependabot")) 134 143 expect_true(calls$replaced) 144 + expect_true(calls$formatted) 135 145 }) 136 146 137 147 test_that("pkg_setup skips optional sections when disabled", { 138 148 called <- FALSE 149 + formatted <- FALSE 139 150 140 151 testthat::local_mocked_bindings( 141 152 use_testthat = function() NULL, ··· 155 166 NULL 156 167 }, 157 168 find_replace_in_file = function(from, to, file, fixed = TRUE) NULL, 169 + try_air_jarl_format = function() { 170 + formatted <<- TRUE 171 + NULL 172 + }, 158 173 .package = "bootstrapper" 159 174 ) 160 175 ··· 165 180 ) 166 181 ) 167 182 expect_false(called) 183 + expect_true(formatted) 168 184 }) 169 185 170 186 test_that("configure_gha runs expected usethis, replacement, and air/jarl calls", {