mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-28 06:31:58 +00:00
Make local and remote ports configurable (#84958)
* Add local_port to startup parameters * Added help to vscode-web * Fixed help text. Changed to show additional message only when local port is changed.
This commit is contained in:
parent
a08ccb351e
commit
7021e20522
@ -20,17 +20,35 @@ const EXTENSIONS_ROOT = path.join(APP_ROOT, 'extensions');
|
||||
const WEB_MAIN = path.join(APP_ROOT, 'src', 'vs', 'code', 'browser', 'workbench', 'workbench-dev.html');
|
||||
|
||||
const args = minimist(process.argv, {
|
||||
string: [
|
||||
boolean:[
|
||||
'no-launch',
|
||||
'scheme',
|
||||
'host'
|
||||
'help'
|
||||
],
|
||||
string: [
|
||||
'scheme',
|
||||
'host',
|
||||
'port',
|
||||
'local_port'
|
||||
],
|
||||
number: [
|
||||
'port'
|
||||
]
|
||||
});
|
||||
|
||||
if(args.help){
|
||||
console.log(
|
||||
'yarn web [options]\n' +
|
||||
' --no-launch Do not start browser\n' +
|
||||
' --scheme Protocol (https or http)\n' +
|
||||
' --host Remote host\n' +
|
||||
' --port Remote/Local port\n' +
|
||||
' --local_port Local port override\n' +
|
||||
' --help\n' +
|
||||
'[Example]\n' +
|
||||
' yarn web --no-launch --scheme https --host example.com --port 8080 --local_port 30000'
|
||||
);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const PORT = args.port || process.env.PORT || 8080;
|
||||
const LOCAL_PORT = args.local_port || process.env.LOCAL_PORT || PORT;
|
||||
const SCHEME = args.scheme || process.env.VSCODE_SCHEME || 'http';
|
||||
const HOST = args.host || 'localhost';
|
||||
const AUTHORITY = process.env.VSCODE_AUTHORITY || `${HOST}:${PORT}`;
|
||||
@ -65,8 +83,10 @@ const server = http.createServer((req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
server.listen(PORT, () => {
|
||||
console.log(`Web UI available at ${SCHEME}://${AUTHORITY}`);
|
||||
server.listen(LOCAL_PORT, () => {
|
||||
if(LOCAL_PORT !== PORT)
|
||||
console.log(`Operating location at http://0.0.0.0:${LOCAL_PORT}`);
|
||||
console.log(`Web UI available at ${SCHEME}://${AUTHORITY}`);
|
||||
});
|
||||
|
||||
server.on('error', err => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user