You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.1 KiB

4 years ago
  1. <?php
  2. /*
  3. * Customize this file as desired. See https://github.com/drush-ops/drush/blob/8.x/examples/policy.drush.inc for documentation.
  4. */
  5. /**
  6. * Implements drush_hook_COMMAND_validate().
  7. *
  8. * Encourage folks to use `composer` instead of Drush pm commands
  9. */
  10. function drush_policy_pm_updatecode_validate() {
  11. return _deny_message();
  12. }
  13. function drush_policy_pm_update_validate() {
  14. return _deny_message();
  15. }
  16. function drush_policy_pm_download_validate() {
  17. return _deny_message();
  18. }
  19. function _deny_message() {
  20. if (!drush_get_option('pm-force')) {
  21. $msg = 'This codebase is assembled with Composer instead of Drush. Use `composer update` and `composer require` instead of `drush pm-updatecode` and `drush pm-download`. You may override this error by using the --pm-force option.';
  22. return drush_set_error('POLICY_PM_DENY', dt($msg));
  23. }
  24. }
  25. /**
  26. * Implements hook_drush_help_alter().
  27. */
  28. function policy_drush_help_alter(&$command) {
  29. if (in_array($command['command'], array('pm-updatecode', 'pm-update', 'pm-download'))) {
  30. $command['options']['pm-force'] = 'Override site policy and allow Drush codebase management (pm-* commands)';
  31. }
  32. }