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,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);