Skip to content

Commit e9fd416

Browse files
committed
up: update some for cmd build and run
1 parent cb7f01b commit e9fd416

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Diff for: src/Cmd/AbstractCmdBuilder.php

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Toolkit\Sys\Cmd;
1111

1212
use RuntimeException;
13+
use Toolkit\Stdlib\Helper\Assert;
1314
use Toolkit\Stdlib\Str;
1415
use Toolkit\Sys\Exec;
1516
use function trim;
@@ -141,6 +142,10 @@ protected function innerExecute(string $command, string $workDir): void
141142
$this->printMessage("> $command", self::PRINT_CMD);
142143
}
143144

145+
if ($workDir) {
146+
Assert::isDir($workDir, "workdir is not exists. path: $workDir");
147+
}
148+
144149
if ($this->dryRun) {
145150
$this->output = 'DRY-RUN: Command execute success';
146151
// Color::println($output, 'cyan');

Diff for: src/Cmd/CmdBuilder.php

-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace Toolkit\Sys\Cmd;
1111

12-
use Toolkit\Stdlib\Helper\Assert;
1312
use Toolkit\Stdlib\Str;
1413
use function sprintf;
1514

@@ -164,10 +163,6 @@ public function run(bool $printOutput = false): static
164163
{
165164
$this->printOutput = $printOutput;
166165

167-
if ($workDir = $this->workDir) {
168-
Assert::isDir($workDir, "workdir is not exists. path: $workDir");
169-
}
170-
171166
$command = $this->buildCommandLine();
172167
$this->innerExecute($command, $this->workDir);
173168

0 commit comments

Comments
 (0)