Skip to content
This repository was archived by the owner on Jun 9, 2023. It is now read-only.

Commit fa9656d

Browse files
Merge pull request drush-ops#1592 from greg-1-anderson/bootstrap-hook
Add a path for commandfiles that is loaded during locate_root
2 parents f18f62f + 99068f4 commit fa9656d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

includes/bootstrap.inc

+22
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,12 @@ function drush_get_bootstrap_candidate_classnames() {
160160
return $candidates;
161161
}
162162

163+
/**
164+
* Look up the best bootstrap class for the given location
165+
* from the set of available candidates.
166+
*/
163167
function drush_bootstrap_class_for_root($path) {
168+
drush_load_bootstrap_commandfile_at_path($path);
164169
$candidates = drush_get_bootstrap_candidates();
165170
foreach ($candidates as $candidate) {
166171
if ($candidate->valid_root($path)) {
@@ -170,6 +175,23 @@ function drush_bootstrap_class_for_root($path) {
170175
return NULL;
171176
}
172177

178+
/**
179+
* Check to see if there is a bootstrap class available
180+
* at the specified location; if there is, load it.
181+
*/
182+
function drush_load_bootstrap_commandfile_at_path($path) {
183+
static $paths = array();
184+
185+
if (!empty($path) && (!array_key_exists($path, $paths))) {
186+
$paths[$path] = TRUE;
187+
// Check to see if we have any bootstrap classes in this location.
188+
$bootstrap_class_dir = $path . '/drush/bootstrap';
189+
if (is_dir($bootstrap_class_dir)) {
190+
_drush_add_commandfiles(array($bootstrap_class_dir), DRUSH_BOOTSTRAP_DRUSH);
191+
}
192+
}
193+
}
194+
173195
/**
174196
* Select the bootstrap class to use. If this is called multiple
175197
* times, the bootstrap class returned might change on subsequent

0 commit comments

Comments
 (0)