Executes a command synchronously and returns the result.
Blocks the main loop until the command completes. Use execAsync for non-blocking execution.
The transformed stdout on success, or transformed stderr on failure
const user = exec('whoami');const parsed = exec('cat config.json', JSON.parse); Copy
const user = exec('whoami');const parsed = exec('cat config.json', JSON.parse);
Optional
Executes a command synchronously and returns the result.
Blocks the main loop until the command completes. Use execAsync for non-blocking execution.