diff --git a/src/Action/JSLinter.php b/src/Action/JSLinter.php index 5ee4ac4..2e71a41 100644 --- a/src/Action/JSLinter.php +++ b/src/Action/JSLinter.php @@ -13,6 +13,7 @@ use function count; use function escapeshellarg; use function preg_match; +use function sprintf; final class JSLinter extends Action { @@ -44,9 +45,10 @@ protected function doExecute(Config $config, IO $io, Repository $repository, Con $result = $this->lintFile($file, $linterCommand, $linterOptions); - $io->write($result['output']); - - if ($result['success'] !== true) { + if ($result['success'] === true) { + $io->write($result['output']); + } else { + $io->writeError(sprintf('%s', $result['error'])); $this->throwError($action, $io); } } @@ -85,6 +87,7 @@ protected function lintFile(string $file, string $linterCommand, string $linterO return [ 'success' => $result->isSuccessful(), 'output' => $result->getStdOut(), + 'error' => $result->getStdErr(), ]; } } diff --git a/src/Action/JSPrettier.php b/src/Action/JSPrettier.php index 9174b41..70645e9 100644 --- a/src/Action/JSPrettier.php +++ b/src/Action/JSPrettier.php @@ -13,6 +13,7 @@ use function count; use function escapeshellarg; use function preg_match; +use function sprintf; final class JSPrettier extends Action { @@ -44,9 +45,10 @@ protected function doExecute(Config $config, IO $io, Repository $repository, Con $result = $this->lintFile($file, $prettierCommand, $prettierOptions); - $io->write($result['output']); - - if ($result['success'] !== true) { + if ($result['success'] === true) { + $io->write($result['output']); + } else { + $io->writeError(sprintf('%s', $result['error'])); $this->throwError($action, $io); } } @@ -85,6 +87,7 @@ protected function lintFile(string $file, string $prettierCommand, string $prett return [ 'success' => $result->isSuccessful(), 'output' => $result->getStdOut(), + 'error' => $result->getStdErr(), ]; } }