From 808359ba6c285b2596e5bffd94e5e9ce7a0918ab Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 12 Jan 2024 18:26:00 +0100 Subject: [PATCH] fix(driver): add external commands only for JS binding (#28968) Motivation: Before this change if a language binding invoked the CLI with `--help` or without any arguments (which will also show the help text) it was suggesting that test/merge-reports/show-report is something we support. After this change this does not get shown anymore. --- packages/playwright-core/src/cli/cli.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/playwright-core/src/cli/cli.ts b/packages/playwright-core/src/cli/cli.ts index 7286f2f837..8681efe73a 100755 --- a/packages/playwright-core/src/cli/cli.ts +++ b/packages/playwright-core/src/cli/cli.ts @@ -53,13 +53,18 @@ const kExternalPlaywrightTestCommands = [ ['show-report', 'Show Playwright Test HTML report.'], ['merge-reports', 'Merge Playwright Test Blob reports'], ]; -for (const [command, description] of kExternalPlaywrightTestCommands) { - const playwrightTest = program.command(command).allowUnknownOption(true); - playwrightTest.description(`${description} Available in @playwright/test package.`); - playwrightTest.action(async () => { - printPlaywrightTestError(command); - gracefullyProcessExitDoNotHang(1); - }); +function addExternalPlaywrightTestCommands() { + for (const [command, description] of kExternalPlaywrightTestCommands) { + const playwrightTest = program.command(command).allowUnknownOption(true); + playwrightTest.description(`${description} Available in @playwright/test package.`); + playwrightTest.action(async () => { + printPlaywrightTestError(command); + gracefullyProcessExitDoNotHang(1); + }); + } } +if (!process.env.PW_LANG_NAME) + addExternalPlaywrightTestCommands(); + program.parse(process.argv);