File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ import path from 'path';
22
22
import program from 'commander' ;
23
23
import os from 'os' ;
24
24
import fs from 'fs' ;
25
- import { runServer , printApiJson , installBrowsers } from './driver' ;
25
+ import { runServer , printApiJson , launchBrowserServer , installBrowsers } from './driver' ;
26
26
import { showTraceViewer } from './traceViewer/traceViewer' ;
27
27
import * as playwright from '../..' ;
28
28
import { BrowserContext } from '../client/browserContext' ;
@@ -162,6 +162,8 @@ if (process.argv[2] === 'run-driver')
162
162
runServer ( ) ;
163
163
else if ( process . argv [ 2 ] === 'print-api-json' )
164
164
printApiJson ( ) ;
165
+ else if ( process . argv [ 2 ] === 'launch-server' )
166
+ launchBrowserServer ( process . argv [ 3 ] , process . argv [ 4 ] ) ;
165
167
else
166
168
program . parse ( process . argv ) ;
167
169
Original file line number Diff line number Diff line change 18
18
19
19
import fs from 'fs' ;
20
20
import path from 'path' ;
21
+ import * as playwright from '../..' ;
22
+ import { BrowserType } from '../client/browserType' ;
23
+ import { LaunchServerOptions } from '../client/types' ;
21
24
import { DispatcherConnection } from '../dispatchers/dispatcher' ;
22
25
import { PlaywrightDispatcher } from '../dispatchers/playwrightDispatcher' ;
23
26
import { installBrowsersWithProgressBar } from '../install/installer' ;
@@ -53,6 +56,15 @@ export function runServer() {
53
56
new PlaywrightDispatcher ( dispatcherConnection . rootDispatcher ( ) , playwright ) ;
54
57
}
55
58
59
+ export async function launchBrowserServer ( browserName : string , configFile ?: string ) {
60
+ let options : LaunchServerOptions = { } ;
61
+ if ( configFile )
62
+ options = JSON . parse ( fs . readFileSync ( configFile ) . toString ( ) ) ;
63
+ const browserType = ( playwright as any ) [ browserName ] as BrowserType ;
64
+ const server = await browserType . launchServer ( options ) ;
65
+ console . log ( server . wsEndpoint ( ) ) ;
66
+ }
67
+
56
68
export async function installBrowsers ( browserNames ?: BrowserName [ ] ) {
57
69
await installBrowsersWithProgressBar ( browserNames ) ;
58
70
}
You can’t perform that action at this time.
0 commit comments