Skip to content

Commit a4b5217

Browse files
committed
Build Phar: show more debug information
* Number of files added for each PHAR. * Total time the script took to run.
1 parent f4bec0a commit a4b5217

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

scripts/build-phar.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
exit(1);
2222
}
2323

24+
$startTime = microtime(true);
25+
2426
$scripts = [
2527
'phpcs',
2628
'phpcbf',
@@ -51,6 +53,7 @@
5153
$rdi = new \RecursiveDirectoryIterator($srcDir, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
5254
$di = new \RecursiveIteratorIterator($rdi, 0, \RecursiveIteratorIterator::CATCH_GET_CHILD);
5355

56+
$fileCount = 0;
5457
foreach ($di as $file) {
5558
$filename = $file->getFilename();
5659

@@ -66,7 +69,9 @@
6669

6770
$path = 'src'.substr($fullpath, $srcDirLen);
6871
$phar->addFile($fullpath, $path);
69-
}
72+
73+
++$fileCount;
74+
}//end foreach
7075

7176
// Add autoloader.
7277
$phar->addFile(realpath(__DIR__.'/../autoload.php'), 'autoload.php');
@@ -75,6 +80,7 @@
7580
$phar->addFile(realpath(__DIR__.'/../licence.txt'), 'licence.txt');
7681

7782
echo 'done'.PHP_EOL;
83+
echo "\t Added ".$fileCount.' files'.PHP_EOL;
7884

7985
/*
8086
Add the stub.
@@ -93,3 +99,16 @@
9399

94100
echo 'done'.PHP_EOL;
95101
}//end foreach
102+
103+
$timeTaken = ((microtime(true) - $startTime) * 1000);
104+
if ($timeTaken < 1000) {
105+
$timeTaken = round($timeTaken);
106+
echo "DONE in {$timeTaken}ms".PHP_EOL;
107+
} else {
108+
$timeTaken = round(($timeTaken / 1000), 2);
109+
echo "DONE in $timeTaken secs".PHP_EOL;
110+
}
111+
112+
echo PHP_EOL;
113+
echo 'Filesize generated phpcs.phar file: '.filesize(dirname(__DIR__).'/phpcs.phar').' bytes'.PHP_EOL;
114+
echo 'Filesize generated phpcs.phar file: '.filesize(dirname(__DIR__).'/phpcbf.phar').' bytes'.PHP_EOL;

0 commit comments

Comments
 (0)