run_command_safe: Run a command safely and return the result

View source: R/utils.R

run_command_safeR Documentation

Run a command safely and return the result

Description

Wraps processx::run() with consistent error handling. Returns a list with status, stdout, and stderr. Never throws: a command that cannot be started, fails, or times out is reported as a non-zero status, so a diagnostic probe cannot abort the calling session.

Usage

run_command_safe(command, args = character(), timeout = 30, env = NULL)

Arguments

command

Character command to run.

args

Character vector of arguments.

timeout

Numeric timeout in seconds. Default 30.

env

Environment for the child process. NULL (the default) inherits the current environment; otherwise the supplied value is used, where the special "current" entry extends rather than replaces it. In every case NODE_COMPILE_CACHE is added so Node's compile cache is written to a temporary directory that is removed when the call returns.

Details

processx is used rather than base::system2() because a modified env is honored on every platform (system2's env is a no-op on Windows for programs like node and python), and arguments are passed as an argv array without shell quoting.

Value

List with status, stdout, stderr.


shinyelectron documentation built on Dec. 3, 2026, 9:07 a.m.