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; + } } } };