From f0102a6667259645a1ce3b9b46088ac9fc86942a Mon Sep 17 00:00:00 2001 From: Amalija Ramljak Date: Tue, 17 Dec 2024 15:26:37 +0100 Subject: [PATCH 1/2] NGSTACK-957 read and output stderr from eslint and prettier --- src/Action/JSLinter.php | 8 +++++--- src/Action/JSPrettier.php | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Action/JSLinter.php b/src/Action/JSLinter.php index 5ee4ac4..4e28438 100644 --- a/src/Action/JSLinter.php +++ b/src/Action/JSLinter.php @@ -44,9 +44,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 +86,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..e8de498 100644 --- a/src/Action/JSPrettier.php +++ b/src/Action/JSPrettier.php @@ -44,9 +44,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 +86,7 @@ protected function lintFile(string $file, string $prettierCommand, string $prett return [ 'success' => $result->isSuccessful(), 'output' => $result->getStdOut(), + 'error' => $result->getStdErr(), ]; } } From d883e34b642e5eb61d76901ce3230f615f53f723 Mon Sep 17 00:00:00 2001 From: Amalija Ramljak Date: Tue, 17 Dec 2024 15:54:50 +0100 Subject: [PATCH 2/2] NGSTACK-957 fix php-cs-fixer --- src/Action/JSLinter.php | 1 + src/Action/JSPrettier.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Action/JSLinter.php b/src/Action/JSLinter.php index 4e28438..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 { diff --git a/src/Action/JSPrettier.php b/src/Action/JSPrettier.php index e8de498..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 {