Skip to content

Commit

Permalink
Move --early processing after preflight.
Browse files Browse the repository at this point in the history
  • Loading branch information
weitzman authored and greg-1-anderson committed Jul 9, 2014
1 parent cedc75b commit e20d40a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
44 changes: 22 additions & 22 deletions drush.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,34 +48,34 @@ function drush_main() {
drush_set_context('DRUSH_BOOTSTRAP_OBJECT', $bootstrap);
$bootstrap->preflight();

if ($file = drush_get_option('early', FALSE)) {
require_once $file;
$function = 'drush_early_' . basename($file, '.inc');
if (function_exists($function)) {
if ($return = $function()) {
// If the function returns FALSE, we continue and attempt to bootstrap
// as normal. Otherwise, we exit early with the returned output.
if ($return === TRUE) {
$return = '';
}
drush_postflight();
return $return;
}
}
}

// Process initial global options such as --debug.
_drush_preflight_global_options();

$return = '';
drush_preflight();
if (!drush_get_error()) {
// Do any necessary preprocessing operations on the command,
// perhaps handling immediately.
$command_handled = drush_preflight_command_dispatch();
if (!$command_handled) {
$bootstrap = drush_get_context('DRUSH_BOOTSTRAP_OBJECT');
$return = $bootstrap->bootstrap_and_dispatch();
if ($file = drush_get_option('early', FALSE)) {
require_once $file;
$function = 'drush_early_' . basename($file, '.inc');
if (function_exists($function)) {
if ($return = $function()) {
// If the function returns FALSE, we continue and attempt to bootstrap
// as normal. Otherwise, we exit early with the returned output.
if ($return === TRUE) {
$return = '';
}
return $return;
}
}
}
else {
// Do any necessary preprocessing operations on the command,
// perhaps handling immediately.
$command_handled = drush_preflight_command_dispatch();
if (!$command_handled) {
$bootstrap = drush_get_context('DRUSH_BOOTSTRAP_OBJECT');
$return = $bootstrap->bootstrap_and_dispatch();
}
}
}
drush_postflight();
Expand Down
2 changes: 0 additions & 2 deletions includes/complete.inc
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,6 @@ function drush_complete_rebuild() {
$complete = array();
// Bootstrap to the site level (if possible) - commands may need to check
// the bootstrap level, and perhaps bootstrap higher in extraordinary cases.
$bootstrap = drush_get_context('DRUSH_BOOTSTRAP_OBJECT');
$bootstrap->preflight();
drush_bootstrap_max(DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION);
$commands = drush_get_commands();
foreach ($commands as $command_name => $command) {
Expand Down
2 changes: 1 addition & 1 deletion tests/completeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static function setUpBeforeClass() {
}

public function testComplete() {
$this->markTestSkipped('@todo Bootstrap refactor has broken this.');
// $this->markTestSkipped('@todo Bootstrap refactor has broken this.');

// We copy our completetest commandfile into our path.
// We cannot use --include since complete deliberately avoids drush
Expand Down

0 comments on commit e20d40a

Please sign in to comment.