Load or reload all modules which are defined in the named directory.
load_all_modules(path = root_config$get_all()[[1L]], pattern = "[^_]\\.[Rr](?:md|nw)?$", full.names = TRUE, recursive = TRUE, strict = TRUE, ...)
path | a character vector of full path names; the default
corresponds to the working directory, |
---|---|
pattern | an optional regular expression. Only file names which match the regular expression will be returned. |
full.names | a logical value. If |
recursive | logical. Should the listing recurse into directories? |
strict | A flag. Should stop at errors? |
... | Further arguments to be passed to |
It is considered a very bad practice to define, touch, undefine, load, make, reset, or perform any other operation from within a module definition that may alterate the internal state of modulr.
load_module
, make_all
, and
reset
.
reset()#> [2018-12-02T17:14:04 CET] Resetting modulr state ... OKtmp_dir <- tempfile("modulr_") dir.create(tmp_dir) tmp_file <- file.path(tmp_dir, "foo.R") cat('define("foo", NULL, function() print("Hello World!"))', file = tmp_file) tmp_file <- file.path(tmp_dir, "bar.R") cat('define("bar", NULL, function() print("hELLO wORLD?"))', file = tmp_file) load_all_modules(tmp_dir)#> [2018-12-02T17:14:05 CET] Defining 'bar' ... OK #> [2018-12-02T17:14:05 CET] Defining 'foo' ... OKmake_all()#> [2018-12-02T17:14:05 CET] Making 'bar' ... #> [2018-12-02T17:14:05 CET] * Visiting and defining dependencies ... #> [2018-12-02T17:14:05 CET] * Constructing dependency graph ... OK #> [1] "hELLO wORLD?" #> [2018-12-02T17:14:05 CET] DONE ('bar' in 0.028 secs) #> [2018-12-02T17:14:05 CET] Making 'foo' ... #> [2018-12-02T17:14:05 CET] * Visiting and defining dependencies ... #> [2018-12-02T17:14:05 CET] * Constructing dependency graph ... OK #> [1] "Hello World!" #> [2018-12-02T17:14:05 CET] DONE ('foo' in 0.032 secs)unlink(tmp_dir, recursive = TRUE)