3

I use this command to get a list of contrib enabled modules:

drush pm-list --type=module --status=enabled --no-core --format=list

Problem is, it also lists submodules, for example:

admin_menu
admin_menu_toolbar

So if I use this to reinstall the modules on another site:

Drush dl admin_menu admin_menu_toolbar

It causes errors. So I need to drush only:

Drush dl admin_menu

So how can I get the list of ONLY parent modules?

My goal is to get drush to display list of modules on the source site, but only folder names, not subfolders

1

When installing the modules, if you use "drush pm-enable ..." ("drush en ..." for short) drush will sort out the dependencies for you and just download the ones you need.

http://drushcommands.com/drush-7x/pm/pm-enable/

  • Yes this will work, however, i need the list WITHOUT dependencies first, repopulating is not the problem. I am trying to get the list of parent modules, without the dependencies. The same thing one can see when viewing modules in Windows Explorer – Bruno Vincent Jan 13 '16 at 9:54
  • But if, as you say, you are trying to reinstalling on another site, and you use drush en, you do not need this list. If you need it for another reason perhaps you should edit your question to make that clearer? – Alfred Armstrong Jan 13 '16 at 10:15
  • I edited the question, it's about fetching modules list, not reinstalling – Bruno Vincent Jan 13 '16 at 14:06
  • Why not use a make file instead? Drush will both create and consume the same file, and only "main" modules will be included – Clive Jan 13 '16 at 14:40
  • @BrunoVincent it's still not clear to me why you want the list of modules. What are you planning to do with it if not to reinstall on another site? It's always a good idea to state the underlying problem you are trying to solve - that way you may get a better answer. – Alfred Armstrong Jan 13 '16 at 14:46
3

You are looking for the pm-projectinfo command. See: http://drushcommands.com/drush-8x/pm/pm-projectinfo/

In Drupal, "projects" contain "extensions". An "extension" can be either a module or a theme. drush pm-list will show a list of modules and themes; drush pm-projectinfo shows a list of projects.

UPDATE: If you want to convert an existing site into a reproducible, buildable script, you might also be interested in using Composer. See https://github.com/drupal-composer/drupal-project and https://www.drupal.org/project/composer_generate

  • That IS what I am using actually, but I need the parent modules, list, WITHOUT the subfolders...is there a folder list command? If I have 2 folders, A and B, a contains folder 1,2 and B contains folder 3,4 , I want the list as folder A,B, not A,1,2,B,3,4 – Bruno Vincent Jan 14 '16 at 0:29
  • In your original question, you said you were using pm-list. I suggest you try pm-projectinfo. In particular, drush pm-projectinfo --format=list --fields=path. – greg_1_anderson Jan 14 '16 at 3:20
0

Ok, found a solution. If someone can add how to do this with Drush it would be great, but not sure if possible...

I use the command prompt in Windows 7:

C:\layouts\sites\all\modules

Then:

 DIR /B C:\layouts\sites\all\modules

This gives me a very clear, clean list of modules WITHOUT subfolders.

I can then use this list to repopulate sites without errors.

0

Since I don't have high enough reputation to comment on Greg's, I post a new answer - which is a minor improvement to Greg's answer:

drush pm-projectinfo --format=list --fields=x,y --status=enabled

This works because the list format returns the array key if multiple fields are selected - no matter what the fields are called ;-) The benefit of this compared to just listing the directory content is that you can use the status filter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.