From a06212af1a86bd1a286df08d446356633628004f Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 4 Jun 2019 21:03:30 -0400 Subject: [PATCH] write failed responses to stderr --- jslib | 2 +- src/program.ts | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/jslib b/jslib index 802d38f5..a1823f99 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 802d38f52e9794567179b9bd9ffc475ceb31323f +Subproject commit a1823f9931173b982fee10ba4cb84c0ee5078fc3 diff --git a/src/program.ts b/src/program.ts index a405c9a1..d1748cd2 100644 --- a/src/program.ts +++ b/src/program.ts @@ -20,11 +20,12 @@ import { Response } from 'jslib/cli/models/response'; import { StringResponse } from 'jslib/cli/models/response/stringResponse'; const chalk = chk.default; -const writeLn = (s: string, finalLine: boolean = false) => { +const writeLn = (s: string, finalLine: boolean = false, error: boolean = false) => { + const stream = error ? process.stderr : process.stdout; if (finalLine && process.platform === 'win32') { - process.stdout.write(s); + stream.write(s); } else { - process.stdout.write(s + '\n'); + stream.write(s + '\n'); } }; @@ -58,8 +59,8 @@ export class Program extends BaseProgram { }); program.on('command:*', () => { - writeLn(chalk.redBright('Invalid command: ' + program.args.join(' '))); - writeLn('See --help for a list of available commands.', true); + writeLn(chalk.redBright('Invalid command: ' + program.args.join(' ')), false, true); + writeLn('See --help for a list of available commands.', true, true); process.exitCode = 1; });