From 7021e20522283a6df4ec01407af39549f456c514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A9=BA=E9=9B=B2?= <54426986+SoraKumo001@users.noreply.github.com> Date: Mon, 18 Nov 2019 19:00:05 +0900 Subject: [PATCH] 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. --- scripts/code-web.js | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/scripts/code-web.js b/scripts/code-web.js index 123d8261a9e..3c7f2d7a489 100755 --- a/scripts/code-web.js +++ b/scripts/code-web.js @@ -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 => {