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.
This commit is contained in:
Max Schmitt 2024-01-12 18:26:00 +01:00 committed by GitHub
parent 8936885a67
commit 808359ba6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,6 +53,7 @@ const kExternalPlaywrightTestCommands = [
['show-report', 'Show Playwright Test HTML report.'], ['show-report', 'Show Playwright Test HTML report.'],
['merge-reports', 'Merge Playwright Test Blob reports'], ['merge-reports', 'Merge Playwright Test Blob reports'],
]; ];
function addExternalPlaywrightTestCommands() {
for (const [command, description] of kExternalPlaywrightTestCommands) { for (const [command, description] of kExternalPlaywrightTestCommands) {
const playwrightTest = program.command(command).allowUnknownOption(true); const playwrightTest = program.command(command).allowUnknownOption(true);
playwrightTest.description(`${description} Available in @playwright/test package.`); playwrightTest.description(`${description} Available in @playwright/test package.`);
@ -61,5 +62,9 @@ for (const [command, description] of kExternalPlaywrightTestCommands) {
gracefullyProcessExitDoNotHang(1); gracefullyProcessExitDoNotHang(1);
}); });
} }
}
if (!process.env.PW_LANG_NAME)
addExternalPlaywrightTestCommands();
program.parse(process.argv); program.parse(process.argv);