Skip to content

Commit b8c8461

Browse files
Fixed The "isolated" option does not exist.
1 parent 7deeef3 commit b8c8461

File tree

8 files changed

+23
-9
lines changed

8 files changed

+23
-9
lines changed

src/Concerns/Isolatable.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ protected function isolationMutex(): Mutex
2626

2727
protected function isolatedStatusCode(): int
2828
{
29-
return (int) (is_numeric($this->option(Options::ISOLATED)) ? $this->option(Options::ISOLATED) : self::SUCCESS);
29+
return (int) (is_numeric($this->getIsolateOption()) ? $this->getIsolateOption() : self::SUCCESS);
30+
}
31+
32+
protected function getIsolateOption(): int|bool
33+
{
34+
return $this->hasIsolateOption() ? $this->option(Options::ISOLATED) : false;
35+
}
36+
37+
protected function hasIsolateOption(): bool
38+
{
39+
return $this->hasOption(Options::ISOLATED) && $this->option(Options::ISOLATED);
3040
}
3141
}

src/Concerns/Optionable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function availableOptions(): array
5050
[Options::REALPATH, null, InputOption::VALUE_NONE, 'Indicate any provided action file paths are pre-resolved absolute path'],
5151
[Options::STEP, null, InputOption::VALUE_OPTIONAL, 'Force the actions to be run so they can be rolled back individually'],
5252
[Options::MUTE, null, InputOption::VALUE_NONE, 'Turns off the output of informational messages'],
53-
[Options::ISOLATED, null, InputOption::VALUE_OPTIONAL, 'Do not run the actions command if another instance of the actions command is already running'],
53+
[Options::ISOLATED, null, InputOption::VALUE_OPTIONAL, 'Do not run the actions command if another instance of the actions command is already running', false],
5454
];
5555
}
5656

src/Console/Command.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use DragonCode\LaravelActions\Concerns\ConfirmableTrait;
88
use DragonCode\LaravelActions\Concerns\Isolatable;
99
use DragonCode\LaravelActions\Concerns\Optionable;
10-
use DragonCode\LaravelActions\Constants\Options;
1110
use DragonCode\LaravelActions\Processors\Processor;
1211
use DragonCode\LaravelActions\Values\Options as OptionsDto;
1312
use Illuminate\Console\Command as BaseCommand;
@@ -37,17 +36,17 @@ public function handle(): int
3736

3837
protected function execute(InputInterface $input, OutputInterface $output): int
3938
{
40-
if ($this->option(Options::ISOLATED) !== false && ! $this->isolationCreate()) {
41-
$this->comment(sprintf('The [%s] command is already running.', $this->getName()));
39+
try {
40+
if ($this->getIsolateOption() !== false && ! $this->isolationCreate()) {
41+
$this->comment(sprintf('The [%s] command is already running.', $this->getName()));
4242

43-
return $this->isolatedStatusCode();
44-
}
43+
return $this->isolatedStatusCode();
44+
}
4545

46-
try {
4746
return parent::execute($input, $output);
4847
}
4948
finally {
50-
if ($this->option(Options::ISOLATED) !== false) {
49+
if ($this->getIsolateOption() !== false) {
5150
$this->isolationForget();
5251
}
5352
}

src/Console/Fresh.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ class Fresh extends Command
2323
Options::PATH,
2424
Options::REALPATH,
2525
Options::MUTE,
26+
Options::ISOLATED,
2627
];
2728
}

src/Console/Migrate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ class Migrate extends Command
2323
Options::PATH,
2424
Options::REALPATH,
2525
Options::MUTE,
26+
Options::ISOLATED,
2627
];
2728
}

src/Console/Refresh.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ class Refresh extends Command
2121
Options::PATH,
2222
Options::REALPATH,
2323
Options::MUTE,
24+
Options::ISOLATED,
2425
];
2526
}

src/Console/Reset.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ class Reset extends Command
2121
Options::PATH,
2222
Options::REALPATH,
2323
Options::MUTE,
24+
Options::ISOLATED,
2425
];
2526
}

src/Console/Rollback.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ class Rollback extends Command
2222
Options::REALPATH,
2323
Options::STEP,
2424
Options::MUTE,
25+
Options::ISOLATED,
2526
];
2627
}

0 commit comments

Comments
 (0)