File tree Expand file tree Collapse file tree 1 file changed +30
-16
lines changed Expand file tree Collapse file tree 1 file changed +30
-16
lines changed Original file line number Diff line number Diff line change 12
12
$ phar ->addFile ('autoload.php ' );
13
13
$ phar ->addFile ('bin/diffFilter ' );
14
14
15
- $ code = realpath (__DIR__ . '/src ' );
16
- $ codeLength = strlen ($ code );
17
- $ directory = new RecursiveDirectoryIterator (
18
- $ code ,
19
- RecursiveDirectoryIterator::FOLLOW_SYMLINKS
20
- );
21
- $ iterator = new RecursiveIteratorIterator (
22
- $ directory ,
23
- 0 ,
24
- RecursiveIteratorIterator::CATCH_GET_CHILD
25
- );
26
15
27
- foreach ($ iterator as $ file ) {
28
- $ fullPath = $ file ->getPathname ();
29
- $ path = 'src ' . substr ($ fullPath , $ codeLength );
16
+ $ dirs = [
17
+ 'src ' ,
18
+ 'vendor ' ,
19
+ ];
30
20
31
- $ phar ->addFile ($ path );
21
+ foreach ($ dirs as $ dir ) {
22
+ addDir ($ dir , $ phar );
32
23
}
33
24
34
25
$ phar ->setStub (
35
26
"#!/usr/bin/env php
36
27
<?php
37
- require 'src/Runners/generic.php';
28
+ require 'phar:// $ pharName / src/Runners/generic.php';
38
29
__HALT_COMPILER(); "
39
30
);
31
+
32
+ function addDir ($ dir , $ phar )
33
+ {
34
+ $ code = realpath (__DIR__ . "/ $ dir/ " );
35
+ $ codeLength = strlen ($ code );
36
+ $ directory = new RecursiveDirectoryIterator (
37
+ $ code ,
38
+ RecursiveDirectoryIterator::FOLLOW_SYMLINKS
39
+ );
40
+ $ iterator = new RecursiveIteratorIterator (
41
+ $ directory ,
42
+ 0 ,
43
+ RecursiveIteratorIterator::CATCH_GET_CHILD
44
+ );
45
+
46
+ foreach ($ iterator as $ file ) {
47
+ $ fullPath = $ file ->getPathname ();
48
+ $ path = $ dir . substr ($ fullPath , $ codeLength );
49
+ if (is_file ($ path )) {
50
+ $ phar ->addFile ($ path );
51
+ }
52
+ }
53
+ }
You can’t perform that action at this time.
0 commit comments