executeCommandRunUntilError
codebolt.terminal.executeCommandRunUntilError(command: string, executeInMain: boolean): Promise
Executes a given command and keeps running until an error occurs.
Listens for messages from the WebSocket and resolves the promise when an error is encountered.
Parameters
Name | Type | Description |
---|---|---|
command | string | The command to be executed. |
executeInMain | boolean | Optional parameter to execute in main terminal. Defaults to false. |
Example
// Run command until error occurs
try {
const errorResult = await codebolt.terminal.executeCommandRunUntilError('npm run dev');
console.log('Command stopped due to error:', errorResult);
} catch (error) {
console.error('Command execution failed:', error.message);
}
// Run in main terminal
try {
const result = await codebolt.terminal.executeCommandRunUntilError('npm start', true);
console.log('Main terminal error:', result);
} catch (error) {
console.error('Main terminal execution failed:', error.message);
}