Skip to content

Commit d33232d

Browse files
Merge pull request #80 from TheDragonCode/3.x
Added logging when skipping action launches
2 parents badbc29 + c89fc05 commit d33232d

File tree

1 file changed

+28
-22
lines changed

1 file changed

+28
-22
lines changed

src/Services/Migrator.php

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,20 @@ public function runUp(string $filename, int $batch, Options $options): void
4949
$name = $this->resolveActionName($path);
5050

5151
if ($this->allowAction($action, $name, $options)) {
52-
$this->hasAction($action, '__invoke')
53-
? $this->runAction($action, $name, '__invoke')
54-
: $this->runAction($action, $name, 'up');
52+
$this->notification->task($name, function () use ($action, $name, $batch) {
53+
$this->hasAction($action, '__invoke')
54+
? $this->runAction($action, '__invoke')
55+
: $this->runAction($action, 'up');
5556

56-
if ($this->allowLogging($action)) {
57-
$this->log($name, $batch);
58-
}
57+
if ($this->allowLogging($action)) {
58+
$this->log($name, $batch);
59+
}
60+
});
61+
62+
return;
5963
}
64+
65+
$this->notification->twoColumn($name, 'SKIP');
6066
}
6167

6268
public function runDown(string $filename, Options $options): void
@@ -65,34 +71,34 @@ public function runDown(string $filename, Options $options): void
6571
$action = $this->resolveAction($path);
6672
$name = $this->resolveActionName($path);
6773

68-
if (! $this->hasAction($action, '__invoke') && $this->hasAction($action, 'down')) {
69-
$this->runAction($action, $name, 'down');
70-
}
74+
$this->notification->task($name, function () use ($action, $name) {
75+
if (! $this->hasAction($action, '__invoke') && $this->hasAction($action, 'down')) {
76+
$this->runAction($action, 'down');
77+
}
7178

72-
$this->deleteLog($name);
79+
$this->deleteLog($name);
80+
});
7381
}
7482

7583
protected function hasAction(Action $action, string $method): bool
7684
{
7785
return method_exists($action, $method);
7886
}
7987

80-
protected function runAction(Action $action, string $name, string $method): void
88+
protected function runAction(Action $action, string $method): void
8189
{
82-
$this->notification->task($name, function () use ($action, $method) {
83-
if ($this->hasAction($action, $method)) {
84-
try {
85-
$this->runMethod($action, $method, $action->enabledTransactions(), $action->transactionAttempts());
90+
if ($this->hasAction($action, $method)) {
91+
try {
92+
$this->runMethod($action, $method, $action->enabledTransactions(), $action->transactionAttempts());
8693

87-
$action->success();
88-
}
89-
catch (Throwable $e) {
90-
$action->failed();
94+
$action->success();
95+
}
96+
catch (Throwable $e) {
97+
$action->failed();
9198

92-
throw $e;
93-
}
99+
throw $e;
94100
}
95-
});
101+
}
96102
}
97103

98104
protected function runMethod(Action $action, string $method, bool $transactions, int $attempts): void

0 commit comments

Comments
 (0)