@@ -28,6 +28,7 @@ class PharController extends Controller
2828 * @options
2929 * --dir STRING Setting the directory for packing.
3030 * - default is current work-dir.(<comment>{workDir}</comment>)
31+ * --fast BOOL Fast build. only add modified files by <cyan>git status -s</cyan>
3132 * --output STRING Setting the output file name(<comment>app.phar</comment>)
3233 * --refresh BOOL Whether build vendor folder files on phar file exists(<comment>False</comment>)
3334 * @param \Inhere\Console\IO\Input $in
@@ -38,21 +39,26 @@ public function packCommand($in, $out): int
3839 {
3940 $ time = microtime (1 );
4041 $ workDir = $ in ->getPwd ();
41- $ dir = $ in ->getOpt ('dir ' ) ?: $ workDir ;
42- $ pharFile = $ workDir . '/ ' . $ in ->getOpt ('output ' , 'app.phar ' );
4342
43+ $ dir = $ in ->getOpt ('dir ' ) ?: $ workDir ;
4444 $ cpr = $ this ->configCompiler ($ dir );
4545
4646 $ counter = null ;
4747 $ refresh = $ in ->boolOpt ('refresh ' );
48+ $ pharFile = $ workDir . '/ ' . $ in ->getOpt ('output ' , 'app.phar ' );
49+
50+ // use fast build
51+ if ($ this ->input ->boolOpt ('fast ' )) {
52+ $ cpr ->setModifies ($ cpr ->findChangedByGit ());
53+ $ this ->output ->liteNote ('Use fast build, will only pack changed or new files(from git status) ' );
54+ }
4855
4956 $ out ->liteInfo (
5057 "Now, will begin building phar package. \n from path: <comment> $ workDir</comment> \n" .
5158 " phar file: <info> $ pharFile</info> "
5259 );
5360
5461 $ out ->info ('Pack file to Phar: ' );
55-
5662 $ cpr ->onError (function ($ error ) {
5763 $ this ->output ->warning ($ error );
5864 });
@@ -63,7 +69,6 @@ public function packCommand($in, $out): int
6369 });
6470 } else {
6571 $ counter = Show::counterTxt ('Handling ... ' , 'Done. ' );
66-
6772 $ cpr ->onAdd (function () use ($ counter ) {
6873 $ counter ->send (1 );
6974 });
@@ -72,6 +77,7 @@ public function packCommand($in, $out): int
7277 // packing ...
7378 $ cpr ->pack ($ pharFile , $ refresh );
7479
80+ // end
7581 if ($ counter ) {
7682 $ counter ->send (-1 );
7783 }
@@ -94,9 +100,8 @@ public function packCommand($in, $out): int
94100 */
95101 protected function configCompiler (string $ dir ): PharCompiler
96102 {
97- $ cpr = new PharCompiler ($ dir );
98-
99103 // config
104+ $ cpr = new PharCompiler ($ dir );
100105 $ cpr
101106 // ->stripComments(false)
102107 ->setShebang (true )
0 commit comments