From 88ccb5dfd6d8d4b277b46292029a7cff568ad43d Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Sun, 20 Feb 2022 19:54:49 +0300 Subject: [PATCH] perf: tweak up error logging --- src/main/ts/runner.ts | 3 ++- src/main/ts/util.ts | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/ts/runner.ts b/src/main/ts/runner.ts index c9f2c599..764b6783 100644 --- a/src/main/ts/runner.ts +++ b/src/main/ts/runner.ts @@ -50,9 +50,10 @@ export const runSync = (_flags: TFlags = {}, _flow?: TFlow): void => { try { exec(flow.main, ctx) - } catch (err) { + } catch (err: any) { ctx.err = err + !flags.silent && console.error((err.error || err.status || err)?.toString()) exec(flow.fallback, ctx) throw err diff --git a/src/main/ts/util.ts b/src/main/ts/util.ts index 467a4379..26e2769e 100644 --- a/src/main/ts/util.ts +++ b/src/main/ts/util.ts @@ -35,10 +35,8 @@ export const invoke = ( ? ['inherit', 'inherit', 'inherit'] : [null, null, null] // eslint-disable-line const result = cp.spawnSync(cmd, args, { cwd, stdio }) - const err = result.error || result.status - if (!skipError && err) { - !silent && console.error(chalk.bold('err'), err?.toString().trim()) + if (!skipError && (result.error || result.status)) { throw result }