Repository navigation
Expand file tree
/
Copy pathlaunch.R
More file actions
45 lines (45 loc) · 1.44 KB
/
Copy pathlaunch.R
File metadata and controls
45 lines (45 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# GateLabR — clone + source convenience launcher.
#
# Keeps the original workflow working unchanged:
# source("path/to/GateLabR/launch.R")
# launchGatingApp()
#
# (If you installed GateLabR as a package instead, use:
# library(GateLabR); launchGatingApp() )
#
# This shim sources the small R/SCE host and both launchers from the clone.
local({
target <- parent.env(environment())
candidates <- character(0)
for (i in seq_len(sys.nframe())) {
f <- sys.frame(i)
if (is.null(f$ofile)) next
candidates <- c(
candidates,
dirname(normalizePath(f$ofile, mustWork = FALSE))
)
}
candidate <- normalizePath(getwd(), mustWork = FALSE)
repeat {
candidates <- c(candidates, candidate)
parent <- dirname(candidate)
if (identical(parent, candidate)) break
candidate <- parent
}
candidates <- unique(candidates)
roots <- candidates[file.exists(file.path(
candidates,
"R",
"host_bridge.R"
))]
if (length(roots) == 0L) {
stop("Could not locate the GateLabR source clone.", call. = FALSE)
}
root <- roots[[1]]
# Every file under R/, so a function added in a new file (memberships.R, coldata_overlay.R)
# is defined here as it is in the installed package. The files only define functions, so
# the order does not matter; sorted keeps it deterministic.
for (file in sort(list.files(file.path(root, "R"), pattern = "\\.R$"))) {
sys.source(file.path(root, "R", file), envir = target)
}
})