Skip to content

Commit a7729da

Browse files
Adjusts @redux-devtools/cli --open flag to respect protocol and host (#1217)
* Adjusts the location open uses Currently when using open, the cli will ignore the host and protocol and always open `http://localhost`. This pr adjusts the open script to use the options protocol and host and default back to localhost if not provided. * adds changeset * fixes grammar * adjusts electron path to respect protocol and host as well Co-authored-by: Nathan Bierema <[email protected]>
1 parent 69833d3 commit a7729da

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

.changeset/long-doors-shout.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@redux-devtools/cli': patch
3+
---
4+
5+
Updates `--open` flag to respect protocol and host when provided

packages/redux-devtools-cli/app/electron.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ function createWindow() {
99
height: 600,
1010
});
1111

12-
mainWindow.loadURL('http://localhost:' + (argv.port ? argv.port : 8000));
12+
const port = argv.port ? argv.port : 8000;
13+
const host = argv.host ? argv.host : 'localhost';
14+
const protocol = argv.protocol ? argv.protocol : 'http';
15+
16+
mainWindow.loadURL(protocol + '://' + host + ':' + port);
1317
}
1418

1519
app.whenReady().then(() => {

packages/redux-devtools-cli/src/bin/openApp.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ export default async function openApp(app: true | string, options: Options) {
1111
if (app === true || app === 'electron') {
1212
try {
1313
const port = options.port ? `--port=${options.port}` : '';
14+
const host = options.host ? `--host=${options.host}` : '';
15+
const protocol = options.protocol ? `--protocol=${options.protocol}` : '';
16+
1417
// eslint-disable-next-line @typescript-eslint/no-var-requires
1518
spawn(require('electron') as string, [
1619
path.join(
@@ -20,6 +23,8 @@ export default async function openApp(app: true | string, options: Options) {
2023
'app'
2124
),
2225
port,
26+
host,
27+
protocol,
2328
]);
2429
} catch (error) {
2530
/* eslint-disable no-console */
@@ -42,7 +47,7 @@ export default async function openApp(app: true | string, options: Options) {
4247
}
4348

4449
await open(
45-
`http://localhost:${options.port}/`,
50+
`${options.protocol}://${options.host ?? 'localhost'}:${options.port}/`,
4651
app !== 'browser' ? { app: { name: app } } : undefined
4752
);
4853
}

0 commit comments

Comments
 (0)