1010
1111class ExtractBuildCommand extends Command
1212{
13- protected $ signature = 'app:extract-build ' ;
13+ protected $ signature = 'app:extract-build {--all} ' ;
1414 protected $ description = 'Extracts the build from the tar file after the build process. ' ;
1515
1616 /** @var \Wtyd\GitHooks\Build\Build */
@@ -25,20 +25,40 @@ public function handle()
2525 {
2626 $ this ->title ('Extract build ' );
2727
28- $ this ->task (
29- ' <fg=yellow>1. Extracting build</> ' ,
30- $ this ->extractBuild ()
31- );
28+ $ allBuilds = boolval ($ this ->option ('all ' ));
3229
33- $ this ->task (
34- ' <fg=yellow>2. Check build</> ' ,
35- $ this ->checkBuild ()
36- );
30+ if ($ allBuilds ) {
31+ $ this ->task (
32+ ' <fg=yellow>1. Extracting all builds</> ' ,
33+ function () {
34+ $ builds = Build::ALL_BUILDS ;
35+ foreach ($ builds as $ tarFile ) {
36+ $ this ->extractBuild ($ tarFile );
37+ }
38+ }
39+ );
40+ } else {
41+ $ this ->task (
42+ ' <fg=yellow>1. Extracting build</> ' ,
43+ $ this ->extractBuild ()
44+ );
45+
46+ $ this ->task (
47+ ' <fg=yellow>2. Check build</> ' ,
48+ $ this ->checkBuild ()
49+ );
50+ }
3751 }
3852
39- private function extractBuild (): void
53+ /**
54+ * Files are in directory with him name. For example ./githooks-7.1/githooks-7.1.tar
55+ *
56+ * @param string $tarName For example: 'githooks-7.1.tar'
57+ */
58+ private function extractBuild ($ tarName = null ): void
4059 {
41- $ zipFile = File::name ($ this ->build ->getTarName ()) . DIRECTORY_SEPARATOR . $ this ->build ->getTarName ();
60+ $ tarName = $ tarName ?? $ this ->build ->getTarName ();
61+ $ zipFile = File::name ($ tarName ) . DIRECTORY_SEPARATOR . $ tarName ;
4262 $ zip = new PharData ($ zipFile );
4363 $ resultado = $ zip ->extractTo ('./ ' , null , true ); // extract to $this->build->getBuildPath();
4464 if (true === $ resultado ) {
0 commit comments