Commit 84665cc5 authored by Jon Pugh's avatar Jon Pugh

Adding a $throw_drush_error parameter to provision_process(), to allow...

Adding a $throw_drush_error parameter to provision_process(), to allow implementors to avoid crashing drush if a process fails. Also adding doc block.
parent 498ea507
......@@ -442,8 +442,25 @@ function provision_backend_invoke($target, $command, $arguments = array(), $data
* $process = drush_get_context('provision_process_result');
* print $process->getExitCode();
*
* @param string $command
* The command to run
* @param null $cwd
* The directory to run the command in.
* @param string $label
* A string to display above the command block in the front-end.
* @param array $env
* A list of environment variables to set for the process.
* @param bool $log_output
* Whether or not to send output to drush_log in real time.
* @param null $error_message
* The error message to show after a failure. Defaults to NULL because the UI turning red and the error output is usually enough.
* @param bool $throw_drush_error
* Whether or not to throw a drush error if the process fails. Defaults to TRUE.
*
* @return string|void
* The output or error output of the command.
*/
function provision_process($command, $cwd = null, $label = 'Process', $env = array(), $log_output = TRUE, $error_message = NULL) {
function provision_process($command, $cwd = null, $label = 'Process', $env = array(), $log_output = TRUE, $error_message = NULL, $throw_drush_error = TRUE) {
if (empty($command)) {
return;
}
......@@ -481,7 +498,10 @@ function provision_process($command, $cwd = null, $label = 'Process', $env = arr
}
else {
drush_log('', 'p_error');
drush_set_error('PROVISION_PROCESS_ERROR', dt($error_message));
if ($throw_drush_error) {
drush_set_error('PROVISION_PROCESS_ERROR', dt($error_message));
}
return $process->getErrorOutput();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment