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 <nbierema@gmail.com>
This commit is contained in:
smacpherson64 2023-01-08 13:25:09 -06:00 committed by GitHub
parent 69833d35b2
commit a7729dae87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
'@redux-devtools/cli': patch
---
Updates `--open` flag to respect protocol and host when provided

View File

@ -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(() => {

View File

@ -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(
@ -20,6 +23,8 @@ export default async function openApp(app: true | string, options: Options) {
'app'
),
port,
host,
protocol,
]);
} catch (error) {
/* eslint-disable no-console */
@ -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
);
}