Skip to content

Commit

Permalink
Merge pull request #51 from exussum12/optimisePhar
Browse files Browse the repository at this point in the history
Shrink phar size
  • Loading branch information
exussum12 authored Oct 15, 2018
2 parents de7f673 + 8384ca4 commit 3623b9d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ composer.lock
diff.txt
phpmd.xml
phpmd-tests.xml
diffFilter.phar
19 changes: 18 additions & 1 deletion CreatePhar.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php

chdir(__DIR__);

$pharName = 'diffFilter.phar';

cleanUp($pharName);

$pharFile = getcwd() . '/diffFilter.phar';

if (file_exists($pharFile)) {
Expand Down Expand Up @@ -47,8 +52,20 @@ function addDir($dir, $phar)
foreach ($iterator as $file) {
$fullPath = $file->getPathname();
$path = $dir . substr($fullPath, $codeLength);

if (strpos($path, '/test/') !== false) {
continue;
}

if (is_file($path)) {
$phar->addFile($path);
$phar->addFromString($path, php_strip_whitespace($path));
}
}
}

function cleanUp($pharName)
{
shell_exec("rm -rf vendor");
shell_exec("rm $pharName");
shell_exec("composer install --no-dev -o");
}

0 comments on commit 3623b9d

Please sign in to comment.