Skip to content

Commit 5ca4657

Browse files
committed
Allow generating stubs for directory
1 parent 4008704 commit 5ca4657

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

scripts/dev/gen_stub.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,23 @@
1515
}
1616

1717
if ($argc >= 2) {
18-
// Generate single file.
19-
processStubFile($argv[1]);
18+
if (is_file($argv[1])) {
19+
// Generate single file.
20+
processStubFile($argv[1]);
21+
} else if (is_dir($argv[1])) {
22+
processDirectory($argv[1]);
23+
} else {
24+
echo "$argv[1] is neither a file nor a directory.\n";
25+
exit(1);
26+
}
2027
} else {
2128
// Regenerate all stub files we can find.
29+
processDirectory('.');
30+
}
31+
32+
function processDirectory(string $dir) {
2233
$it = new RecursiveIteratorIterator(
23-
new RecursiveDirectoryIterator('.'),
34+
new RecursiveDirectoryIterator($dir),
2435
RecursiveIteratorIterator::LEAVES_ONLY
2536
);
2637
foreach ($it as $file) {

0 commit comments

Comments
 (0)