-
Notifications
You must be signed in to change notification settings - Fork 5
/
generate_aliases.php
executable file
·46 lines (43 loc) · 1.2 KB
/
generate_aliases.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
$path = $argv[1];
if(!is_dir($path)) {
print $path . ' is not a valid path';
exit;
}
print '<?php';
print PHP_EOL;
print '/**' . PHP_EOL;
print ' * Your own custom alias file courtesy of https://github.com/mrf/generate-drush-aliases' . PHP_EOL;
print ' */';
print PHP_EOL;
print PHP_EOL;
function build_alias($value,$entry) {
print "// $value";
print PHP_EOL;
print "\$aliases['" . $value. "'] = array(" . PHP_EOL;
print " 'uri' => '" . $value . ".dev'," . PHP_EOL;
print " 'root' => '$entry'," . PHP_EOL;
print ");" . PHP_EOL;
print PHP_EOL;
}
if($scanned_directory = array_diff(scandir($path), array('..', '.'))) {
foreach($scanned_directory as $value) {
$entry = $path . '/' . $value;
if(is_dir($entry)) {
chdir($entry);
$version = shell_exec('drush core-status --format=list version');
if($version && $version !== '7.0-dev') {
if(file_exists('index.php')) {
build_alias($value,$entry);
} else if (is_dir('docroot')) {
if(file_exists('index.php')) {
// Special logic for Acquia repos
chdir('docroot');
$entry = $entry . '/docroot';
build_alias($value,$entry);
}
}
}
}
}
}