summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Pugh2018-09-14 12:43:33 (GMT)
committerJon Pugh2018-09-14 12:43:33 (GMT)
commit84665cc59bf3058175be611246e9517de3000761 (patch)
treef6723845382a818572a9473660c4fbb0417d88a1
parent498ea5074d608da827a62d28c15822d0801fe213 (diff)
Adding a $throw_drush_error parameter to provision_process(), to allow implementors to avoid crashing drush if a process fails. Also adding doc block.7.x-3.160-beta3
-rw-r--r--provision.inc24
1 files changed, 22 insertions, 2 deletions
diff --git a/provision.inc b/provision.inc
index fd4f705..daea97c 100644
--- a/provision.inc
+++ b/provision.inc
@@ -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();
}
}