Skip to content

Commit 923a1b6

Browse files
committed
🐛 fix bin path if rector is not in $PATH directories
1 parent 02a3974 commit 923a1b6

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/PartialCommand.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,13 @@ private function askTask(string $file): Task
220220
private function dryRunRector(string $file): bool
221221
{
222222
$this->output->writeln('<fg=white;bg=blue>Checking file ' . $file . ' ...</>');
223-
$exitCode = $this->runCommand("rector process --ansi --no-progress-bar --dry-run " . $file);
223+
$exitCode = $this->runCommand($this->getBinPath() . "rector process --ansi --no-progress-bar --dry-run " . $file);
224224
return $exitCode === 0;
225225
}
226226

227227
private function executeRector(string $file): void
228228
{
229-
$exitCode = $this->runCommand("rector process --ansi --no-progress-bar --no-diffs " . $file);
229+
$exitCode = $this->runCommand($this->getBinPath() . "rector process --ansi --no-progress-bar --no-diffs " . $file);
230230
if ($exitCode) {
231231
exit($exitCode);
232232
}
@@ -243,4 +243,13 @@ private function runCommand(string $command): int
243243
$this->output->writeln('<fg=gray>duration: ' . round($duration, 3) . 's</>', OutputInterface::VERBOSITY_DEBUG);
244244
return $exitCode;
245245
}
246+
247+
private function getBinPath(): string
248+
{
249+
if (isset($GLOBALS['_composer_bin_dir'])) {
250+
return $GLOBALS['_composer_bin_dir'] . '/';
251+
}
252+
253+
return '';
254+
}
246255
}

0 commit comments

Comments
 (0)