Skip to content

Commit 74a7570

Browse files
added output file name option to compress command
1 parent 0adb449 commit 74a7570

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app/Commands/CompressCommand.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
class CompressCommand extends Command
1010
{
11-
protected $signature = 'compress {--exclude= : Directories to exclude from the zip}';
11+
protected $signature = 'compress {--exclude= : Directories to exclude from the zip}
12+
{--output-name|name= : The name of the output zip file}';
1213

1314
protected $description = 'Zip your project with ease.';
1415

@@ -20,8 +21,12 @@ class CompressCommand extends Command
2021

2122
public $zipPath;
2223

24+
public string|null $outputFileName = null;
25+
2326
public function handle()
2427
{
28+
$this->outputFileName = $this->option('name');
29+
2530
$this->projectName = basename(getcwd());
2631

2732
$this->projectPath = getcwd();
@@ -104,7 +109,9 @@ private function getExcludes(): array
104109
private function initializeZipArchive(): ZipArchive|null
105110
{
106111
// Convert folder name to snake case for the zip file name
107-
$zipFileName = config('compress.output_file_name') ?? strtolower(preg_replace('/(?<!\ )[A-Z]/', '_$0', $this->projectName));
112+
$zipFileName = config('compress.output_file_name')
113+
?? $this->outputFileName
114+
?? strtolower(preg_replace('/(?<!\ )[A-Z]/', '_$0', $this->projectName));
108115

109116
// Check if the folder exists
110117
if (! file_exists($this->projectPath)) {

0 commit comments

Comments
 (0)