Skip to content

Commit

Permalink
Test app.R in root standard for rsconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherMarais committed Feb 25, 2024
1 parent ae6f261 commit f1df5f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions 05_DASHBOARD/deploy-dev.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ rsconnect::setAccountInfo(
# Deploy
req_files <- list_all_files(c("./04_Tests", "./03_Data_for_app")) # get all the required files
rsconnect::deployApp(
appDir = "./05_DASHBOARD",
appFiles = c("app.R", req_files),
# appDir = "./05_DASHBOARD",
# appFiles = c("app.R", req_files),
appName = "Dashboard-dev",
forceUpdate = TRUE)
4 changes: 2 additions & 2 deletions 05_DASHBOARD/deploy.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rsconnect::setAccountInfo(

# Deploy
rsconnect::deployApp(
appDir = "./05_DASHBOARD",
appFiles = "app.R",
# appDir = "./05_DASHBOARD",
# appFiles = "app.R",
appName = "Dashboard",
forceUpdate = TRUE)
8 changes: 4 additions & 4 deletions 05_DASHBOARD/app.R → app.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,28 @@ find_directory_of_file <- function(file_name, start_dir=getwd()) {

# find file_name from current working directory
# before trying from a shallower directory
file_name <- "*DASHBOARD/app.R" # The file you are searching for
file_name <- "*app.R" # The file you are searching for

try({
found_dir <- find_directory_of_file(file_name)
# Check if found_dir is NULL or empty, indicating the file was not found
if (is.null(found_dir) || length(found_dir) == 0) {
# print error
print("05_DASHBOARD/app.R not found from current working directory!")
print("app.R not found from current working directory!")
print("trying again from shallower directory")
# trying again from great grandparent directory of working directory
setwd("../../..")
found_dir <- find_directory_of_file(file_name)
if (is.null(found_dir) || length(found_dir) == 0) {
print("05_DASHBOARD/app.R likely does not exist in filesystem!")
print("app.R likely does not exist in filesystem!")
}
# Set working directory to parent directory of found dir
setwd(fs::path_dir(found_dir[1]))
# Print working directory
print(paste0("Working dir: ", getwd()))
}
# Set working directory to parent directory of found dir
setwd(fs::path_dir(found_dir[1]))
setwd(found_dir[1])
# Print working directory
print(paste0("Working dir: ", getwd()))
}, silent = FALSE) # Setting silent = FALSE will print the error message to the console
Expand Down

0 comments on commit f1df5f9

Please sign in to comment.