Skip to content

Commit

Permalink
apacheGH-122 browser: permit serving over https
Browse files Browse the repository at this point in the history
  • Loading branch information
mgatto committed Jul 14, 2023
1 parent 66d9e2e commit 857821c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bin/template/cordova/lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -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');
Expand Down
6 changes: 4 additions & 2 deletions bin/template/cordova/run
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -36,13 +36,15 @@ function start (argv) {
}

function help () {
console.log('\nUsage: run [ --target=<browser> ] [ --port=<number> ]');
console.log('\nUsage: run [ --target=<browser> ] [ --port=<number> ] [ --https]');
console.log(' --target=<browser> : Launches the specified browser. Chrome is default.');
console.log(' --port=<number> : 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);
}

0 comments on commit 857821c

Please sign in to comment.