Skip to content

Commit

Permalink
Sanity check for an app.R or server.R file
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke committed Sep 29, 2023
1 parent 7eb9e40 commit c0cca16
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
7 changes: 5 additions & 2 deletions R/export.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ export <- function(
verbose_print <- if (verbose) message else list

stopifnot(fs::is_dir(appdir))
if (!fs::file_exists(fs::path(appdir, "app.R"))) {
stop("Directory ", appdir, " does not contain an app.R file.")
if (!(
fs::file_exists(fs::path(appdir, "app.R")) ||
fs::file_exists(fs::path(appdir, "server.R"))
)) {
stop("Directory ", appdir, " does not contain an app.R or server.R file.")
}

if (fs::is_absolute_path(subdir)) {
Expand Down
1 change: 1 addition & 0 deletions local/shiny-apps/global-r/global.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global_value <- 50
8 changes: 8 additions & 0 deletions local/shiny-apps/global-r/server.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
library(shiny)


function(input, output) {
output$txt <- renderText({
paste0("The value of n*2 is ", 2 * input$n)
})
}
5 changes: 5 additions & 0 deletions local/shiny-apps/global-r/ui.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fluidPage(
markdown("## `ui.R` / `server.R` / `global.R`"),
sliderInput("n", "N", 0, 100, global_value),
verbatimTextOutput("txt", placeholder = TRUE),
)

0 comments on commit c0cca16

Please sign in to comment.