Skip to content

Commit 2d7311f

Browse files
author
Capacitor+ Bot
committed
chore: sync upstream PR ionic-team#8194 from @Shellishack
2 parents e7059f9 + cf9bb2f commit 2d7311f

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

cli/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ export function runProgram(config: Config): void {
245245
.option('--host <host>', 'Host used for live reload')
246246
.option('--port <port>', 'Port used for live reload')
247247
.option('--configuration <name>', 'Configuration name of the iOS Scheme')
248+
.option('--https', 'Enable HTTPS for live reload server')
248249
.action(
249250
wrapAction(
250251
telemetryAction(
@@ -265,8 +266,8 @@ export function runProgram(config: Config): void {
265266
host,
266267
port,
267268
configuration,
268-
},
269-
) => {
269+
https
270+
}) => {
270271
const { runCommand } = await import('./tasks/run');
271272
await runCommand(config, platform, {
272273
scheme,
@@ -282,6 +283,7 @@ export function runProgram(config: Config): void {
282283
host,
283284
port,
284285
configuration,
286+
https,
285287
});
286288
},
287289
),

cli/src/tasks/run.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface RunCommandOptions {
3434
host?: string;
3535
port?: string;
3636
configuration?: string;
37+
https?: boolean;
3738
}
3839

3940
export async function runCommand(
@@ -92,7 +93,7 @@ export async function runCommand(
9293
}
9394
const cordovaPlugins = await getCordovaPlugins(config, platformName);
9495
if (options.liveReload) {
95-
await CapLiveReloadHelper.editCapConfigForLiveReload(config, platformName, options);
96+
await CapLiveReloadHelper.editCapConfigForLiveReload(config, platformName, options, false, options.https);
9697
if (platformName === config.android.name) {
9798
await await writeCordovaAndroidManifest(cordovaPlugins, config, platformName, true);
9899
}
@@ -108,7 +109,7 @@ export async function runCommand(
108109
})
109110
.then(() => process.exit());
110111
logger.info(
111-
`App running with live reload listing for: http://${options.host}:${options.port}. Press Ctrl+C to quit.`,
112+
`App running with live reload listing for: ${options.https ? 'https' : 'http'}://${options.host}:${options.port}. Press Ctrl+C to quit.`,
112113
);
113114
await sleepForever();
114115
}

cli/src/util/livereload.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class CapLiveReload {
146146
platformName: string,
147147
options: RunCommandOptions,
148148
rootConfigChange = false,
149+
useHttps = false,
149150
): Promise<void> {
150151
const platformAbsPath =
151152
platformName == config.ios.name
@@ -161,7 +162,7 @@ class CapLiveReload {
161162
const configJson = readJSONSync(capConfigPath);
162163
this.configJsonToRevertTo.json = JSON.stringify(configJson, null, 2);
163164
this.configJsonToRevertTo.platformPath = capConfigPath;
164-
const url = `http://${options.host}:${options.port}`;
165+
const url = `${useHttps ? 'https' : 'http'}://${options.host}:${options.port}`;
165166
configJson.server = {
166167
url,
167168
};

0 commit comments

Comments
 (0)