#!/usr/bin/env Rscript # Stand-in for Tools/buildModuleBundlesLocally.R. Upstream's script sapply()s # over the modules, so the first failure aborts every module after it, and it # reinstalls devtools and jaspModuleTools on every call. This compiles each # module on its own, reports failures and carries on. options(repos = 'https://cran.r-project.org', jaspRemoteCellarRedownload = FALSE) workdir <- './ModuleBundleBuildDir' userLibrary <- file.path(workdir, 'LibraryR') dir.create(userLibrary, recursive = TRUE, showWarnings = FALSE) .libPaths(new = userLibrary) if (!requireNamespace('jaspModuleTools', quietly = TRUE)) { for (pkg in c('remotes', 'devtools')) if (!requireNamespace(pkg, quietly = TRUE)) install.packages(pkg, lib = userLibrary) remotes::install_github('jasp-stats/jaspModuleTools', lib = userLibrary) } here <- getwd() failed <- character() for (mod in commandArgs(trailingOnly = TRUE)) { message('==> compiling ', basename(mod)) ok <- tryCatch({ jaspModuleTools::compile(mod, workdir = file.path(workdir, 'build_dir'), resultdir = '../Modules/local', bundleAll = TRUE) TRUE }, error = function(e) { message('==> FAILED ', basename(mod), ': ', conditionMessage(e)) FALSE }) setwd(here) # compile() may leave us elsewhere when it errors if (!ok) failed <- c(failed, basename(mod)) } if (length(failed)) message('==> modules that failed: ', paste(failed, collapse = ' '))