From 20d719c681e5e23488cfa6a494e34e2968133e6a Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdxcode@users.noreply.github.com> Date: Sat, 3 Feb 2018 22:25:36 -0800 Subject: [PATCH] fix: default to display stack trace --- src/config.ts | 1 + src/errors.ts | 2 +- test/errors.test.ts | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 08b45c5e..866ce406 100644 --- a/src/config.ts +++ b/src/config.ts @@ -32,6 +32,7 @@ export class Config { errorsHandled = false context: any = {} errlog?: string + showStackTrace = true constructor() { this.debug = process.env.DEBUG === '*' diff --git a/src/errors.ts b/src/errors.ts index 186a3ef6..3ccc59f1 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -71,7 +71,7 @@ export function getErrorMessage(err: any, opts: {stack?: boolean} = {}): string message, ].join('') - if (opts.stack || process.env.CI || severity === 'fatal' || config.debug) { + if (config.showStackTrace || opts.stack || process.env.CI || severity === 'fatal' || config.debug) { // show stack trace let stack = err.stack || inspect(err) stack = clean(stack, {pretty: true}) diff --git a/test/errors.test.ts b/test/errors.test.ts index 7881ae78..f1cf9730 100644 --- a/test/errors.test.ts +++ b/test/errors.test.ts @@ -7,6 +7,7 @@ describe('errors', () => { .env({CI: null}) .stderr() .it('warns', async output => { + cli.config.showStackTrace = false cli.warn('foobar') if (process.platform === 'win32') { expect(output.stderr).to.equal(' ! Warning: foobar\n')