diff --git a/CHANGELOG.md b/CHANGELOG.md index e9eac54..59a8e7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog @author ᏒᏊᏀᏋᏒ ᏕξᏐ +## [0.3.1] - 2019-09-30 +### Fixed +- PHPCS path for phar fixed +- Util fixed + + ## [0.3.0] - 2019-09-15 ### Changed - Messages are now colored in CLI diff --git a/src/Main.php b/src/Main.php index 34f887d..c7288ea 100644 --- a/src/Main.php +++ b/src/Main.php @@ -323,16 +323,22 @@ public function run(array $options = null): void */ private function validateOptions(): void { + // TODO: Move this validation to a separated class. $base = dirname(__DIR__); // First, we check for basic system requirements. if ($this->isPhar === true) { if (isset($this->options['phpcs']) === true) { - $base = getcwd(); - $this->exitIf( - empty(shell_exec("command -v $base/{$this->options['phpcs']}")), - "'$base/{$this->options['phpcs']}' not valid phpcs command. Please, make sure it exists." - ); + $cwd = getcwd(); + $pathRegular = $this->options['phpcs']; + $pathRelative = "$cwd/{$this->options['phpcs']}"; + if (empty(shell_exec("command -v $pathRegular")) === false) { + $this->options['phpcs'] = $pathRegular; + } elseif (empty(shell_exec("command -v $pathRelative")) === false) { + $this->options['phpcs'] = $pathRelative; + } else { + $this->exit("phpcs not found.\n\nPlease, make sure the given ``--path={$this->options['phpcs']}`` points to the correct path."); + } } else { $this->exitIf( empty(shell_exec('command -v phpcs')),