Skip to content

Commit

Permalink
usethis::use_tidy_style()
Browse files Browse the repository at this point in the history
  • Loading branch information
cderv committed Feb 21, 2024
1 parent ab875ea commit db8f726
Show file tree
Hide file tree
Showing 19 changed files with 127 additions and 127 deletions.
2 changes: 1 addition & 1 deletion R/add.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ quarto_add_extension <- function(extension = NULL, no_prompt = FALSE, quiet = FA
# This will ask for approval or stop installation
check_extension_approval(no_prompt, "Quarto extensions", "https://quarto.org/docs/extensions/managing.html")

args <- c(extension,"--no-prompt", if (quiet) cli_arg_quiet(), quarto_args)
args <- c(extension, "--no-prompt", if (quiet) cli_arg_quiet(), quarto_args)

quarto_add(args, quarto_bin = quarto_bin, echo = TRUE)

Expand Down
1 change: 0 additions & 1 deletion R/backports.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

if (getRversion() < "3.5.0") {
isFALSE <- function(x) identical(x, FALSE)
}
2 changes: 0 additions & 2 deletions R/create.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#'
#' @export
quarto_create_project <- function(name, type = "default", dir = ".", no_prompt = FALSE, quiet = FALSE, quarto_args = NULL) {

check_quarto_version("1.4", "quarto create project", "https://quarto.org/docs/projects/quarto-projects.html")

if (rlang::is_missing(name)) {
Expand All @@ -45,7 +44,6 @@ quarto_create_project <- function(name, type = "default", dir = ".", no_prompt =
owd <- setwd(dir)
on.exit(setwd(owd), add = TRUE, after = FALSE)
quarto_create(args, quarto_bin = quarto_bin, echo = TRUE)

}

quarto_create <- function(args = character(), ...) {
Expand Down
28 changes: 15 additions & 13 deletions R/daemon.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

run_serve_daemon <- function(command, target, wd, extra_args, render, port, host, browse) {

# resolve target if provided
if (!is.null(target)) {
target <- path.expand(target)
Expand Down Expand Up @@ -78,7 +76,7 @@ run_serve_daemon <- function(command, target, wd, extra_args, render, port, host

# wait for port to be bound to
init <- ""
while(!port_active(port)) {
while (!port_active(port)) {
quarto[[ps_key]]$poll_io(50)
cat(quarto[[ps_key]]$read_output())
if (!quarto[[ps_key]]$is_alive()) {
Expand Down Expand Up @@ -114,8 +112,9 @@ run_serve_daemon <- function(command, target, wd, extra_args, render, port, host
if (!isFALSE(browse)) {
if (!is.function(browse)) {
browse <- ifelse(rstudioapi::isAvailable(),
rstudioapi::viewer,
utils::browseURL)
rstudioapi::viewer,
utils::browseURL
)
}
serve_url <- paste0("http://localhost:", port)
browse(serve_url)
Expand Down Expand Up @@ -144,10 +143,11 @@ stop_serve_daemon <- function(command) {
find_port <- function(port) {
for (i in 1:20) {
# determine the port (exclude those considered unsafe by Chrome)
while(TRUE) {
while (TRUE) {
port <- 3000 + sample(5000, 1)
if (!port %in% c(3659, 4045, 6000, 6665:6669,6697))
if (!port %in% c(3659, 4045, 6000, 6665:6669, 6697)) {
break
}
}
# see if it's active
if (!port_active(port)) {
Expand All @@ -158,10 +158,12 @@ find_port <- function(port) {
}

port_active <- function(port) {
tryCatch({
suppressWarnings(con <- socketConnection("127.0.0.1", port, timeout = 1))
close(con)
TRUE
}, error = function(e) FALSE)
tryCatch(
{
suppressWarnings(con <- socketConnection("127.0.0.1", port, timeout = 1))
close(con)
TRUE
},
error = function(e) FALSE
)
}

4 changes: 2 additions & 2 deletions R/inspect.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
#' quarto_inspect(
#' input = "myproject",
#' profile = "advanced"
#' )}
#' )
#' }
#' @importFrom jsonlite fromJSON
#' @export
quarto_inspect <- function(input = ".",
profile = NULL,
quiet = FALSE,
quarto_args = NULL) {

quarto_bin <- find_quarto()

args <- c("inspect", path.expand(input))
Expand Down
22 changes: 11 additions & 11 deletions R/preview.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ quarto_preview <- function(file = NULL,
browse = TRUE,
watch = TRUE,
navigate = TRUE) {

# default for file
if (is.null(file)) {
file = getwd()
file <- getwd()
}

# handle extra_args
Expand All @@ -68,19 +67,20 @@ quarto_preview <- function(file = NULL,
}

# serve
run_serve_daemon("preview",
file,
NULL,
args,
render,
port,
host,
browse)
run_serve_daemon(
"preview",
file,
NULL,
args,
render,
port,
host,
browse
)
}

#' @rdname quarto_preview
#' @export
quarto_preview_stop <- function() {
stop_serve_daemon("preview")
}

Loading

0 comments on commit db8f726

Please sign in to comment.