22# '
33# ' @description
44# ' Creates a subdirectory for results based on the database name within a
5- # ' specified output directory. If the output directory is not provided, the
6- # ' current working directory is used.
5+ # ' specified output directory.
76# '
87# ' @param outputDir Character string. The path to the main output folder.
9- # ' If NULL, defaults to the current working directory. Default NULL .
8+ # ' This must be supplied explicitly .
109# ' @param dbname Character string. The name of the database, used to suffix
1110# ' the results folder (e.g., "results_dbname").
1211# '
3433# ' )
3534# ' unlink(outputDir, recursive = TRUE)
3635createResultsDir <- function (
37- outputDir = NULL ,
36+ outputDir ,
3837 dbname
3938 ) {
39+ if (missing(outputDir )) {
40+ cli :: cli_abort(" {.arg outputDir} must be supplied explicitly." )
41+ }
4042 # Set folder location for results ----
4143 cli :: cli_alert_info(
4244 " Creating locations to save results"
4345 )
44- if (is.null(outputDir )) {
45- outputDir <- getwd()
46- checkmate :: assertDirectoryExists(
47- outputDir
48- )
46+ checkmate :: assertCharacter(outputDir , len = 1 , any.missing = FALSE )
47+ if (! dir.exists(outputDir )) {
48+ dir.create(outputDir , recursive = TRUE )
49+ checkmate :: assertDirectoryExists(outputDir )
4950 } else {
50- if (! dir.exists(outputDir )) {
51- dir.create(outputDir )
52- checkmate :: assertDirectoryExists(outputDir )
53- } else {
54- outputDir <- normalizePath(outputDir )
55- checkmate :: assertDirectoryExists(outputDir )
56- }
51+ outputDir <- normalizePath(outputDir )
52+ checkmate :: assertDirectoryExists(outputDir )
5753 }
5854resultsDirName <- glue :: glue(
5955 " results_{dbname}"
@@ -73,4 +69,4 @@ resultsDirName <- glue::glue(
7369 resultsDirName = resultsDirName
7470 )
7571 )
76- }
72+ }
0 commit comments