Drush feature request: install a module (or theme) into an arbitrarily specified directory
The ability to use the Drush Package Manager (drush pm) to install a module in an arbitrarily specified directory doesn't presently exist.
My use case is to install modules into an installation profile, and not only that but a 'contrib' directory in the modules directory for that installation profile. However, people who want to install modules to subdirectories in the more normal sites/all/modules (or sites/example/modules) will need to be able to set their path also. Moreover, someone who wants to use sites/default/modules instead of sites/all/modules, or sites/all/modules even though they have a sites/example/modules in use, need to be able to set the path for Drush PM to look for installing and upgrading.
Finally, it appears that being able to set the directory is the only substantive thing stopping us from using Drush to install themes, too.
Below are excerpts from drush_pm.module that relate to the installation location, as regards the install command at least:
<?php
/**
* Implementation of hook_help().
*/
function drush_pm_help($section) {
// ...
switch ($section) {
case 'drush:pm install':
return t("Usage: drush [options] pm install <package_1> <package_2> ...
<package_n> is the short name of a project hosted on drupal.org,
or the short name and the version number (Drupal major version is optional).
e.g. project, project-5.x-1.0, project-1.0, project-1.x-dev, project-1.1-rc1
So far, only modules are supported.\n
The modules will be installed into a site specific modules directory if one
exists, otherwise sites/all/modules is used.
After installing, you still have to activate on the normal module
administration page\n\n". $handler);
// ...
/**
* Implementation of hook_drush_command().
*/
function drush_pm_drush_command() {
$items['pm install'] = array(
'callback' => 'drush_pm_install_package',
'description' => 'Install one or more modules'
);
// ...
/**
* Command callback. Installs one or more packages (so far only modules).
*/
function drush_pm_install_package() {
$projects = func_get_args();
if (empty($projects)) {
drush_die(t("No project specified.\n\nRun drush help pm install for more information."));
}
// Parse out project name and version
$projects = drush_pm_parse_package_name($projects);
// If a URI is provided then we install to that specific site, otherwise we install to sites/all/modules
if (DRUSH_URI) {
$path = conf_path();
$modulepath = DRUSH_DRUPAL_ROOT .'/'. $path .'/modules/';
}
if (!isset($modulepath) || !file_exists($modulepath)) {
$modulepath = DRUSH_DRUPAL_ROOT .'/sites/all/modules/';
}
// ...
}
?>
It would be fairly easy to hack in the ability to, say, notice if the first argument passed in after pm install is a "-p" and if so treat the second argument as the path to install to, overriding the two approaches to constructing the module path above.
A proper solution, however, would work for pm update, pm info, and pm status as well. I'm not sure if that means it should be defined in the drush command flags (the [options] mentioned in the help) or if a new place to defined flags after the pm would have to be created for the package manager module.
Comments
Post new comment