Created
June 8, 2016 12:54
-
-
Save derhasi/cbd2efbd7de98c2ea56bb3fdd8682c7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ini = file_get_contents(__DIR__ . '/../make.ini'); | |
/** | |
* @var SplFileInfo $path | |
* @var SplFileInfo $file | |
*/ | |
foreach(new DirectoryIterator(__DIR__ . '/sites/all/modules/contrib') as $path) { | |
$projectname = $path->getFilename(); | |
// extract version. | |
$pattern = '/projects\[' . preg_quote($projectname). '\]\[version\]\ ?\=\ ?"(.*)\"/'; | |
$matches = array(); | |
preg_match($pattern, $ini, $matches); | |
$version = $matches[1]; | |
if (empty($version[1])) { | |
continue; | |
} | |
foreach (new DirectoryIterator($path->getPathname()) as $file) { | |
if ($file->isDir()) { | |
continue; | |
} | |
if ($file->getExtension() == 'info') { | |
if (file_put_contents($file->getPathname(), sprintf(PHP_EOL . 'version = "7.x-%s"', $version), FILE_APPEND)) { | |
echo sprintf('Added version "%s" to "%s"' . "\n", $version, $file->getPathname()); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment