@@ -2,18 +2,26 @@ import * as os from "os";
22import { validatePaths } from "vs/code/node/paths" ;
33import { parseMainProcessArgv } from "vs/platform/environment/node/argvHelper" ;
44import { ParsedArgs } from "vs/platform/environment/common/environment" ;
5- import { buildHelpMessage , buildVersionMessage } from "vs/platform/environment/node/argv" ;
5+ import { buildHelpMessage , buildVersionMessage , options } from "vs/platform/environment/node/argv" ;
66import product from "vs/platform/product/node/product" ;
77import pkg from "vs/platform/product/node/package" ;
88import { MainServer , WebviewServer } from "vs/server/server" ;
99import "vs/server/tar" ;
1010
11+ interface Args extends ParsedArgs {
12+ port ?: string ;
13+ "webview-port" ?: string ;
14+ }
15+
16+ options . push ( { id : "port" , type : "string" , cat : "o" , description : "Port for the main server." } ) ;
17+ options . push ( { id : "webview-port" , type : "string" , cat : "o" , description : "Port for the webview server." } ) ;
18+
1119interface IMainCli {
1220 main : ( argv : ParsedArgs ) => Promise < void > ;
1321}
1422
1523const main = async ( ) : Promise < void > => {
16- const args = validatePaths ( parseMainProcessArgv ( process . argv ) ) ;
24+ const args = validatePaths ( parseMainProcessArgv ( process . argv ) ) as Args ;
1725
1826 if ( ! product . extensionsGallery ) {
1927 product . extensionsGallery = {
@@ -53,8 +61,8 @@ const main = async (): Promise<void> => {
5361 const server = new MainServer ( webviewServer , args ) ;
5462 // The main server inserts webview server address to the root HTML, so we'll
5563 // need to wait for it to listen otherwise the address will be null.
56- await webviewServer . listen ( 8444 ) ;
57- await server . listen ( 8443 ) ;
64+ await webviewServer . listen ( typeof args [ "webview-port" ] !== "undefined" && parseInt ( args [ "webview-port" ] , 10 ) || 8444 ) ;
65+ await server . listen ( typeof args . port !== "undefined" && parseInt ( args . port , 10 ) || 8443 ) ;
5866 console . log ( `Main server serving ${ server . address } ` ) ;
5967 console . log ( `Webview server serving ${ webviewServer . address } ` ) ;
6068} ;
0 commit comments