diff --git a/cli/src/index.ts b/cli/src/index.ts index 68c14bd06a..0cfbacbc8f 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -14,6 +14,15 @@ export async function run(): Promise { program.version(config.cli.package.version); + program + .command('config', { hidden: true }) + .description(`print evaluated Capacitor config`) + .option('--json', 'Print in JSON format') + .action(async ({ json }) => { + const { configCommand } = await import('./tasks/config'); + await configCommand(config, json); + }); + program .command('create [directory] [name] [id]', { hidden: true }) .description('Creates a new Capacitor project') diff --git a/cli/src/tasks/config.ts b/cli/src/tasks/config.ts new file mode 100644 index 0000000000..0f658a5250 --- /dev/null +++ b/cli/src/tasks/config.ts @@ -0,0 +1,17 @@ +import util from 'util'; + +import type { Config } from '../definitions'; +import { output } from '../log'; + +export async function configCommand( + config: Config, + json: boolean, +): Promise { + if (json) { + output.write(JSON.stringify(config)); + } else { + output.write( + `${util.inspect(config, { depth: Infinity, colors: true })}\n`, + ); + } +}