From a1823f9931173b982fee10ba4cb84c0ee5078fc3 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 4 Jun 2019 21:03:15 -0400 Subject: [PATCH] write failed responses to stderr --- src/cli/baseProgram.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cli/baseProgram.ts b/src/cli/baseProgram.ts index b8b6248d05..546eb70147 100644 --- a/src/cli/baseProgram.ts +++ b/src/cli/baseProgram.ts @@ -10,15 +10,17 @@ import { UserService } from '../abstractions/user.service'; const chalk = chk.default; export abstract class BaseProgram { - constructor(private userService: UserService, private writeLn: (s: string, finalLine: boolean) => void) { } + constructor( + private userService: UserService, + private writeLn: (s: string, finalLine: boolean, error: boolean) => void) { } protected processResponse(response: Response, exitImmediately = false, dataProcessor: () => string = null) { if (!response.success) { if (process.env.BW_QUIET !== 'true') { if (process.env.BW_RESPONSE === 'true') { - this.writeLn(this.getJson(response), true); + this.writeLn(this.getJson(response), true, true); } else { - this.writeLn(chalk.redBright(response.message), true); + this.writeLn(chalk.redBright(response.message), true, true); } } if (exitImmediately) { @@ -30,7 +32,7 @@ export abstract class BaseProgram { } if (process.env.BW_RESPONSE === 'true') { - this.writeLn(this.getJson(response), true); + this.writeLn(this.getJson(response), true, false); } else if (response.data != null) { let out: string = dataProcessor != null ? dataProcessor() : null; if (out == null) { @@ -49,7 +51,7 @@ export abstract class BaseProgram { } if (out != null && process.env.BW_QUIET !== 'true') { - this.writeLn(out, true); + this.writeLn(out, true, false); } } if (exitImmediately) {