Skip to content

Commit 1e1500e

Browse files
committed
Throw exception when trying to run an already started command
1 parent a0630fc commit 1e1500e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/MonitoredCommand.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ public function commandRecord()
105105
*/
106106
public function handle()
107107
{
108-
if ( ! $this->passesChecks()) {
108+
if (! $this->passesChecks()) {
109109
return false;
110110
}
111111

112112
try {
113113
$this->commandRecord()->start();
114114
$message = $this->handleCommand();
115115

116-
if ( ! $this->isRecursive) {
116+
if (! $this->isRecursive) {
117117
return $this->complete($message);
118118
}
119119
} catch (\Exception $e) {
@@ -146,7 +146,7 @@ protected function passesChecks()
146146
}
147147

148148
foreach ($this->runsIf as $name) {
149-
if ( ! CommandRecord::hasCompleted($name)) {
149+
if (! CommandRecord::hasCompleted($name)) {
150150
return $this->fail("Command {$name} has not run yet.");
151151
}
152152
}
@@ -158,7 +158,7 @@ protected function passesChecks()
158158
}
159159

160160
if ($this->commandRecord()->hasStarted()) {
161-
return false;
161+
throw new \Exception('The monitored command ' . $this->commandRecord()->id . ' has already started.');
162162
}
163163

164164
return true;
@@ -172,7 +172,8 @@ protected function passesChecks()
172172
protected function hasRunTooManyTimes()
173173
{
174174
return $this->runLimit >= 0 &&
175-
max(CommandRecord::hasBeenRequestedCount($this->name), CommandRecord::hasCompletedCount($this->name)) >= $this->runLimit;
175+
max(CommandRecord::hasBeenRequestedCount($this->name),
176+
CommandRecord::hasCompletedCount($this->name)) >= $this->runLimit;
176177
}
177178

178179
/**

0 commit comments

Comments
 (0)