function drush_find_path_to_drush

8.0.x init.drush.inc drush_find_path_to_drush($home)

Determine where Drush is located, so that we can add that location to the $PATH

1 call to drush_find_path_to_drush()
drush_init_core_init in commands/core/init.drush.inc
Initialize local Drush configuration

File

commands/core/init.drush.inc, line 139
Set up local Drush configuration.

Code

function drush_find_path_to_drush($home) {
  // First test: is Drush inside a vendor directory?
  // Does vendor/bin exist?  If so, use that.  We do
  // not have a good way to locate the 'bin' directory
  // if it has been relocated in the composer.json config
  // section.
  if ($vendor_pos = strpos(DRUSH_BASE_PATH, "/vendor/")) {
    $vendor_dir = substr(DRUSH_BASE_PATH, 0, $vendor_pos + 7);
    $vendor_bin = $vendor_dir . '/bin';
    if (is_dir($vendor_bin)) {
      return $vendor_bin;
    }
  }

  // Fallback is to use the directory that Drush is in.
  return DRUSH_BASE_PATH;
}