From dd047257c6d8b717c79440d9d50274e4204e9604 Mon Sep 17 00:00:00 2001 From: Momo Kornher Date: Thu, 11 Jan 2024 20:20:12 +0000 Subject: [PATCH] fix(cli): running the cli with --debug does not print stack traces (#28669) `--debug` exists for exactly one purpose: Printing source-mapped traces so we can find the code that is going wrong. Let's always enabled tracing when debugging. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/aws-cdk/lib/cli.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/aws-cdk/lib/cli.ts b/packages/aws-cdk/lib/cli.ts index 5574f487a496c..0871e2a42814c 100644 --- a/packages/aws-cdk/lib/cli.ts +++ b/packages/aws-cdk/lib/cli.ts @@ -315,16 +315,17 @@ if (!process.stdout.isTTY) { export async function exec(args: string[], synthesizer?: Synthesizer): Promise { const argv = await parseCommandLineArguments(args); + if (argv.verbose) { + setLogLevel(argv.verbose); + } + if (argv.debug) { enableSourceMapSupport(); } - if (argv.verbose) { - setLogLevel(argv.verbose); - - if (argv.verbose > 2) { - enableTracing(true); - } + // Debug should always imply tracing + if (argv.debug || argv.verbose > 2) { + enableTracing(true); } if (argv.ci) {