From 0cf7dbfb54613bcf841d18867b65570a974349b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgardo=20Avile=CC=81s-Lo=CC=81pez?= Date: Fri, 3 Mar 2023 17:41:40 -0500 Subject: [PATCH] Fix the eslint command supressing the error output --- lib/commands/eslint.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/commands/eslint.js b/lib/commands/eslint.js index 210f087..f6376b5 100644 --- a/lib/commands/eslint.js +++ b/lib/commands/eslint.js @@ -8,7 +8,7 @@ module.exports = { command, describe: 'Check the codebase with ESLint.', handler: async () => { - const { $ } = await import('zx/core'); + const { $, ProcessOutput } = await import('zx/core'); process.env.FORCE_COLOR = '3'; if (process.argv[2] === command) { process.argv.splice(2, 1); @@ -17,10 +17,15 @@ module.exports = { try { $.verbose = false; await $`./node_modules/.bin/eslint ${process.argv.slice(2)}`; - } catch (/** @type {*} */ err) { - const { exitCode, stdout } = err; - console.error(stdout.replace('\n', '').trimEnd()); - process.exit(exitCode); + } catch (err) { + if (err instanceof ProcessOutput) { + const { exitCode, stdout, stderr } = err; + const out = stdout?.toString() || stderr?.toString() || ''; + console.error(out.replace('\n', '').trimEnd()); + process.exit(exitCode || 1); + } else { + throw err; + } } } };