Skip to content

Commit

Permalink
Adjusts @redux-devtools/cli --open flag to respect protocol and host (
Browse files Browse the repository at this point in the history
#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]>
  • Loading branch information
smacpherson64 and Methuselah96 authored Jan 8, 2023
1 parent 69833d3 commit a7729da
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-doors-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@redux-devtools/cli': patch
---

Updates `--open` flag to respect protocol and host when provided
6 changes: 5 additions & 1 deletion packages/redux-devtools-cli/app/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ function createWindow() {
height: 600,
});

mainWindow.loadURL('http://localhost:' + (argv.port ? argv.port : 8000));
const port = argv.port ? argv.port : 8000;
const host = argv.host ? argv.host : 'localhost';
const protocol = argv.protocol ? argv.protocol : 'http';

mainWindow.loadURL(protocol + '://' + host + ':' + port);
}

app.whenReady().then(() => {
Expand Down
7 changes: 6 additions & 1 deletion packages/redux-devtools-cli/src/bin/openApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export default async function openApp(app: true | string, options: Options) {
if (app === true || app === 'electron') {
try {
const port = options.port ? `--port=${options.port}` : '';
const host = options.host ? `--host=${options.host}` : '';
const protocol = options.protocol ? `--protocol=${options.protocol}` : '';

// eslint-disable-next-line @typescript-eslint/no-var-requires
spawn(require('electron') as string, [
path.join(
Expand All @@ -20,6 +23,8 @@ export default async function openApp(app: true | string, options: Options) {
'app'
),
port,
host,
protocol,
]);
} catch (error) {
/* eslint-disable no-console */
Expand All @@ -42,7 +47,7 @@ export default async function openApp(app: true | string, options: Options) {
}

await open(
`http://localhost:${options.port}/`,
`${options.protocol}://${options.host ?? 'localhost'}:${options.port}/`,
app !== 'browser' ? { app: { name: app } } : undefined
);
}

0 comments on commit a7729da

Please sign in to comment.