3434
3535# ' @rdname module_teal_lockfile
3636ui_teal_lockfile <- function (id ) {
37- if (! requireNamespace(" mirai" , quietly = TRUE ) || ! requireNamespace(" renv" , quietly = TRUE )) {
38- warning(" lockfile feature disabled. `mirai` and `renv` packages must be installed." )
37+ if (! isTRUE(getOption(" teal.renv.enable" ))) {
38+ return (NULL )
39+ } else if (! .is_lockfile_deps_installed()) {
40+ warning(" Lockfile feature disabled. `mirai` and `renv` packages must be installed." )
3941 return (NULL )
4042 }
4143
4244 ns <- NS(id )
43- if (! isTRUE(getOption(" teal.renv.enable" ))) {
44- return (NULL )
45- }
4645 shiny :: tagList(
4746 tags $ span(" " , id = ns(" lockFileStatus" )),
4847 shinyjs :: disabled(downloadLink(ns(" lockFileLink" ), " Download lockfile" ))
@@ -51,7 +50,7 @@ ui_teal_lockfile <- function(id) {
5150
5251# ' @rdname module_teal_lockfile
5352srv_teal_lockfile <- function (id ) {
54- if (! requireNamespace(c( " mirai " , " renv" ), quietly = TRUE )) {
53+ if (! isTRUE(getOption( " teal. renv.enable " )) || ! .is_lockfile_deps_installed( )) {
5554 return (NULL )
5655 }
5756 moduleServer(id , function (input , output , session ) {
@@ -67,10 +66,6 @@ srv_teal_lockfile <- function(id) {
6766 shinyjs :: disable(" lockFileLink" )
6867 }
6968
70- if (! isTRUE(getOption(" teal.renv.enable" ))) {
71- return (NULL )
72- }
73-
7469 lockfile_path <- " teal_app.lock"
7570 shiny :: onStop(function () {
7671 if (file.exists(lockfile_path ) && ! shiny :: isRunning()) {
@@ -193,3 +188,8 @@ utils::globalVariables(c("opts", "sysenv", "libpaths", "wd", "lockfilepath", "ru
193188
194189 list (out = out , res = res )
195190}
191+
192+ # ' @rdname module_teal_lockfile
193+ .is_lockfile_deps_installed <- function () {
194+ requireNamespace(" mirai" , quietly = TRUE ) && requireNamespace(" renv" , quietly = TRUE )
195+ }
0 commit comments