Skip to content

Commit 2f279bd

Browse files
committed
Option to output verbose information
1 parent 6a585af commit 2f279bd

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

src/Commands/Download.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ class Download extends Command
1818

1919
public function handle()
2020
{
21+
config([
22+
'airdrop.verbose' => $this->option('verbose')
23+
]);
24+
2125
$this->makeDriver()->download();
2226
}
2327

src/Commands/Upload.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ class Upload extends Command
1515

1616
public function handle()
1717
{
18+
config([
19+
'airdrop.verbose' => $this->option('verbose')
20+
]);
21+
1822
$this->makeDriver()->upload();
1923
}
2024
}

src/Drivers/BaseDriver.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,16 @@ public function setCurrentHash($hash)
3535
return $this;
3636
}
3737

38+
public function output($line)
39+
{
40+
if (config('airdrop.verbose')) {
41+
echo "[Airdrop] $line\n";
42+
}
43+
}
44+
3845
abstract public function download();
3946

4047
abstract public function upload();
4148

4249

43-
}
50+
}

src/Drivers/FilesystemDriver.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,18 @@ public function upload()
2626
if ($this->exists()) {
2727
// This exact configuration of assets is already stashed,
2828
// so we don't need to do it again.
29+
$this->output('Files already exist on remote storage, not uploading.');
2930
return;
3031
}
3132

3233
$zipPath = $this->localStashPath() . $this->stashedPackageFilename();
3334

35+
$this->output('Making zip file at ' . $zipPath);
36+
3437
$this->makeZip($zipPath);
3538

39+
$this->output('Uploading to remote disk at ' . $this->remoteStashPath() . $this->stashedPackageFilename());
40+
3641
$this->disk()->putFileAs(
3742
$this->remoteStashPath(),
3843
$zipPath,
@@ -74,12 +79,16 @@ public function makeZip($path)
7479
*/
7580
public function download()
7681
{
77-
$this->extract()
82+
if ($this->extract()) {
83+
$this->output('Assets downloaded and extracted.');
7884
// Touch a file that can be used to inform the deploy
7985
// process that building assets can be skipped.
80-
? File::put($this->skipFilePath(), '')
86+
File::put($this->skipFilePath(), '');
87+
} else {
88+
$this->output('Assets did not exist.');
8189
// Remove the file if extraction did not succeed.
82-
: File::delete($this->skipFilePath());
90+
File::delete($this->skipFilePath());
91+
}
8392
}
8493

8594
public function extract()
@@ -178,4 +187,4 @@ protected function localStashPath()
178187

179188
return Str::finish($tmp, '/');
180189
}
181-
}
190+
}

0 commit comments

Comments
 (0)