feat(cli) : allow passing PlaywrightServer.startDefault parameters via cli (#12530)

This commit is contained in:
Siddharth Singha Roy 2022-03-07 22:45:46 +05:30 committed by GitHub
parent d81330f28f
commit a2b3d4f570
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -229,8 +229,11 @@ program
program
.command('run-server', { hidden: true })
.option('--port <port>', 'Server port')
.option('--path <path>', 'Endpoint Path', '/')
.option('--max-clients <maxClients>', 'Maximum clients')
.option('--no-socks-proxy', 'Disable Socks Proxy')
.action(function(options) {
runServer(options.port ? +options.port : undefined).catch(logErrorAndExit);
runServer(options.port ? +options.port : undefined, options.path, options.maxClients ? +options.maxClients : Infinity, options.socksProxy).catch(logErrorAndExit);
});
program

View File

@ -52,8 +52,8 @@ export function runDriver() {
};
}
export async function runServer(port: number | undefined) {
const server = await PlaywrightServer.startDefault({ path: '/', maxClients: Infinity });
export async function runServer(port: number | undefined, path: string = '/', maxClients: number = Infinity, enableSocksProxy: boolean = true) {
const server = await PlaywrightServer.startDefault({ path, maxClients, enableSocksProxy });
const wsEndpoint = await server.listen(port);
process.on('exit', () => server.close().catch(console.error));
console.log('Listening on ' + wsEndpoint); // eslint-disable-line no-console