From 857821c75d776a245f0e67465a3adf28f74f0ba8 Mon Sep 17 00:00:00 2001 From: Michael Gatto Date: Fri, 14 Jul 2023 15:26:52 -0700 Subject: [PATCH] GH-122 browser: permit serving over https --- bin/template/cordova/lib/run.js | 3 ++- bin/template/cordova/run | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/template/cordova/lib/run.js b/bin/template/cordova/lib/run.js index 2502d6b..64381ab 100644 --- a/bin/template/cordova/lib/run.js +++ b/bin/template/cordova/lib/run.js @@ -29,6 +29,7 @@ module.exports.run = function (args) { args.port = args.port || 8000; args.target = args.target || 'default'; // make default the system browser args.noLogOutput = args.silent || false; + args.https = args.https || false; const wwwPath = path.join(__dirname, '../../www'); const manifestFilePath = path.resolve(path.join(wwwPath, 'manifest.json')); @@ -53,7 +54,7 @@ module.exports.run = function (args) { startPage = 'index.html'; } - const projectUrl = (new url.URL(`http://localhost:${server.port}/${startPage}`)).href; + const projectUrl = (new url.URL(` ${(args.https) ? 'https' : 'http'}://localhost:${server.port}/${startPage}`)).href; console.log('startPage = ' + startPage); console.log('Static file server running @ ' + projectUrl + '\nCTRL + C to shut down'); diff --git a/bin/template/cordova/run b/bin/template/cordova/run index 503b80b..46bd114 100755 --- a/bin/template/cordova/run +++ b/bin/template/cordova/run @@ -27,7 +27,7 @@ const args = process.argv; start(args); function start (argv) { - const args = nopt({ help: Boolean, target: String, port: Number }, { help: ['/?', '-h', 'help', '-help', '/help'] }, argv); + const args = nopt({ help: Boolean, target: String, port: Number, https: Boolean }, { help: ['/?', '-h', 'help', '-help', '/help'] }, argv); if (args.help) { help(); } else { @@ -36,13 +36,15 @@ function start (argv) { } function help () { - console.log('\nUsage: run [ --target= ] [ --port= ]'); + console.log('\nUsage: run [ --target= ] [ --port= ] [ --https]'); console.log(' --target= : Launches the specified browser. Chrome is default.'); console.log(' --port= : Http server uses specified port number.'); + console.log(' --https : Http server runs over SSL.'); console.log('Examples:'); console.log(' run'); console.log(' run -- --target=ie'); console.log(' run -- --target=chrome --port=8000'); + console.log(' run -- --target=chrome --port=8000 --https'); console.log(''); process.exit(0); }