function pm_drush_pm_adjust_download_destination

3.x pm.drush.inc pm_drush_pm_adjust_download_destination(&$project, $release)

Built-in adjust-download-destination hook. This particular version of the hook will move modules that contain only drush commands to /usr/share/drush/commands if it exists, or $HOME/.drush if the site-wide location does not exist.

File

commands/pm/pm.drush.inc, line 1445
The drush Package Manager

Code

function pm_drush_pm_adjust_download_destination(&$project, $release) {
  // If this project is a module, but it has no .module file, then
  // check to see if it contains drush commands.  If that is all
  // that it contains, then install it to $HOME/.drush.
  if ($release['type'] == 'module') {
    $module_files = drush_scan_directory($project['full_project_path'], '/.*\.module/');
    if (empty($module_files)) {
      $drush_command_files = drush_scan_directory($project['full_project_path'], '/.*\.drush.inc/');
      if (!empty($drush_command_files)) {
        $install_dir = drush_get_context('SHARE_PREFIX', '/usr') . '/share/drush/commands/';
        if (!is_dir($install_dir)) {
          $install_dir = drush_server_home() . '/.drush/';
        }
        // Make the .drush dir if it does not already exist
        if (!is_dir($install_dir)) {
          mkdir($install_dir);
        }
        // Change the location if the mkdir worked
        if (is_dir($install_dir)) {
          $project['project_install_location'] = $install_dir . basename($project['full_project_path']);
        }
      }
    }
  }
}