exec()
Execute a command on the limbuild server. Returns a ChildProcess-like object with stdout/stderr streams.
The interface is designed to be similar to Node.js’s child_process.spawn() for familiarity and ease of extension.
import { exec } from 'limrun' ;
const proc = exec (
{ command: 'xcodebuild' },
{ apiUrl: '...' , token: '...' }
);
// Stream output
proc . stdout . on ( 'data' , ( chunk ) => console . log ( '[stdout]' , chunk ));
proc . stderr . on ( 'data' , ( chunk ) => console . error ( '[stderr]' , chunk ));
// Wait for completion
const { exitCode , status } = await proc ;
Parameters
Command execution request The command to execute. Currently only ‘xcodebuild’ is supported.
Configuration for xcodebuild command Path to .xcworkspace file
Execution options The API URL of the limbuild server
Auth token for the server
log
(level: 'debug' | 'info' | 'warn' | 'error', msg: string) => void
Custom logging function
Returns
A ChildProcess-like object with stdout/stderr streams. Implements PromiseLike so it can be awaited directly.
Examples
Stream-based (like Node.js spawn)
Promise-based (awaitable)
Kill Running Process
const proc = exec ({ command: 'xcodebuild' }, options );
proc . stdout . on ( 'data' , ( chunk ) => process . stdout . write ( chunk ));
proc . stderr . on ( 'data' , ( chunk ) => process . stderr . write ( chunk ));
proc . on ( 'exit' , ( code ) => console . log ( `Exited with code ${ code } ` ));
ExecChildProcess
A ChildProcess-like object similar to Node.js’s ChildProcess. Implements PromiseLike so it can be awaited directly.
Properties
Stdout stream - emits ‘data’ and ‘close’ events proc . stdout . on ( 'data' , ( chunk : string ) => {
console . log ( chunk );
});
proc . stdout . on ( 'close' , () => {
console . log ( 'stdout closed' );
});
Stderr stream - emits ‘data’ and ‘close’ events proc . stderr . on ( 'data' , ( chunk : string ) => {
console . error ( chunk );
});
The remote process/build identifier (similar to pid in Node.js)
Methods
on()
Listen for process events.
proc . on ( 'exit' , ( code ) => {
console . log ( `Process exited with code ${ code } ` );
});
listener
(code: number) => void
required
Event handler function
kill()
Send a signal to terminate the process.
Promise that resolves when the kill signal has been sent
then()
Promise interface for awaiting the process result.
const { exitCode , status } = await proc ;
Promise that resolves with the execution result
ReadableStream
A Readable-like stream interface, similar to Node.js stream.Readable. Emits ‘data’ for each chunk and ‘close’ when the stream ends.
Methods
on()
Attach event listeners to the stream.
proc . stdout . on ( 'data' , ( chunk ) => console . log ( chunk ));
proc . stdout . on ( 'close' , () => console . log ( 'Stream closed' ));
listener
DataListener | CloseListener
required
Event handler function
For ‘data’ events: (chunk: string) => void
For ‘close’ events: () => void
Types
ExecRequest
type ExecRequest = {
command : 'xcodebuild' ;
xcodebuild ?: {
workspace ?: string ;
project ?: string ;
scheme ?: string ;
};
};
Request object for executing a command.
ExecOptions
type ExecOptions = {
apiUrl : string ;
token : string ;
log ?: ( level : 'debug' | 'info' | 'warn' | 'error' , msg : string ) => void ;
};
Options for command execution.
ExecResult
type ExecResult = {
exitCode : number ;
execId : string ;
status : 'SUCCEEDED' | 'FAILED' | 'CANCELLED' ;
};
Result of command execution.
The exit code of the command (0 for success, non-zero for failure)
The remote execution identifier
status
'SUCCEEDED' | 'FAILED' | 'CANCELLED'
The execution status
SUCCEEDED: exitCode === 0
FAILED: exitCode !== 0 and exitCode !== -1
CANCELLED: exitCode === -1 (killed)