Skip to content

Commit

Permalink
switch to system2 to be able to capture stderr on error
Browse files Browse the repository at this point in the history
  • Loading branch information
Enchufa2 committed Mar 25, 2023
1 parent ba4e974 commit fe498ad
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/Attributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ sourceCpp <- function(file = "",

# prepare the command (output if we are in showOutput mode)
args <- c(
r, "CMD", "SHLIB",
"CMD", "SHLIB",
if (windowsDebugDLL) "-d",
if (rebuild) "--preclean",
if (dryRun) "--dry-run",
Expand All @@ -147,13 +147,13 @@ sourceCpp <- function(file = "",
shQuote(src)
)

cmd <- paste(args, collapse = " ")
if (showOutput)
cat(cmd, "\n") # #nocov
cat(paste(c(r, args), collapse = " "), "\n") # #nocov

# execute the build -- suppressWarnings b/c when showOutput = FALSE
# we are going to explicitly check for an error and print the output
result <- suppressWarnings(system(cmd, intern = !showOutput))
so <- if (showOutput) "" else TRUE
result <- suppressWarnings(system2(r, args, stdout = so, stderr = so))

# check build results
if(!showOutput) {
Expand Down

0 comments on commit fe498ad

Please sign in to comment.