diff --git a/hooks/RoboFile.php b/hooks/RoboFile.php index 0efc34e..08853b6 100644 --- a/hooks/RoboFile.php +++ b/hooks/RoboFile.php @@ -190,12 +190,30 @@ public function updateDependencies() */ protected function getPatches($module) { - $path = 'modules/' . $module . '/patches.json'; - if (file_exists($path)) { - return json_decode(file_get_contents($path)); - } else { - return new stdClass(); - } + // Load composer configuration for the given module. + $config = json_decode(file_get_contents('modules/' . $module . '/composer.json')); + + // If the module defines patches in composer.json, simply use them. + if (!empty($config->extra->{"patches"})) { + return $config->extra->{"patches"}; + } + + // Use the old patch file standard in drupal_tests, which was independent + // from any module composer.json patch specifications. + $patches_file = 'patches.json'; + + // If the module defines an external composer patches file, use it. + if (!empty($config->extra->{"patches-file"})) { + $patches_file = $config->extra->{"patches-file"}; + } + + $path = 'modules/' . $module . '/' . $patches_file; + if (file_exists($path)) { + $patch_file_contents = json_decode(file_get_contents($path)); + return $patch_file_contents->{"patches"}; + } + + return new stdClass(); } /** diff --git a/templates/module/patches.json b/templates/module/patches.json index ef6fee5..31a31df 100644 --- a/templates/module/patches.json +++ b/templates/module/patches.json @@ -1,5 +1,7 @@ { - "drupal/coder": { - "CodeSniffer testing all file extensions instead of the configured ones": "https://www.drupal.org/files/issues/2867601.11-disable-txt-sniffs.patch" + "patches": { + "drupal/coder": { + "CodeSniffer testing all file extensions instead of the configured ones": "https://www.drupal.org/files/issues/2867601.11-disable-txt-sniffs.patch" + } } }