Skip to content

Commit f0102a6

Browse files
NGSTACK-957 read and output stderr from eslint and prettier
1 parent 1c1f32c commit f0102a6

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/Action/JSLinter.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ protected function doExecute(Config $config, IO $io, Repository $repository, Con
4444

4545
$result = $this->lintFile($file, $linterCommand, $linterOptions);
4646

47-
$io->write($result['output']);
48-
49-
if ($result['success'] !== true) {
47+
if ($result['success'] === true) {
48+
$io->write($result['output']);
49+
} else {
50+
$io->writeError(sprintf('<error>%s</error>', $result['error']));
5051
$this->throwError($action, $io);
5152
}
5253
}
@@ -85,6 +86,7 @@ protected function lintFile(string $file, string $linterCommand, string $linterO
8586
return [
8687
'success' => $result->isSuccessful(),
8788
'output' => $result->getStdOut(),
89+
'error' => $result->getStdErr(),
8890
];
8991
}
9092
}

src/Action/JSPrettier.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ protected function doExecute(Config $config, IO $io, Repository $repository, Con
4444

4545
$result = $this->lintFile($file, $prettierCommand, $prettierOptions);
4646

47-
$io->write($result['output']);
48-
49-
if ($result['success'] !== true) {
47+
if ($result['success'] === true) {
48+
$io->write($result['output']);
49+
} else {
50+
$io->writeError(sprintf('<error>%s</error>', $result['error']));
5051
$this->throwError($action, $io);
5152
}
5253
}
@@ -85,6 +86,7 @@ protected function lintFile(string $file, string $prettierCommand, string $prett
8586
return [
8687
'success' => $result->isSuccessful(),
8788
'output' => $result->getStdOut(),
89+
'error' => $result->getStdErr(),
8890
];
8991
}
9092
}

0 commit comments

Comments
 (0)