From 860d867d8b880c4f15863ae097b73cb7e840a907 Mon Sep 17 00:00:00 2001 From: Tomoyuki Aota Date: Mon, 2 Dec 2024 12:53:34 +0900 Subject: [PATCH 1/2] Rename the command line option from --serve to --live-reload. --- package.json | 4 ++-- src-main/command-line-options/parse-command-line-options.ts | 2 +- src-main/live-reload.ts | 2 +- src-main/record-at-app-launch.ts | 2 +- src-shared/command-line-options/command-line-options.ts | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 62b8207f..829ae678 100644 --- a/package.json +++ b/package.json @@ -15,13 +15,13 @@ "scripts": { "postinstall": "electron-builder install-app-deps", "ng": "ng", - "start": "npm-run-all -p ng:serve electron:serve", + "start": "npm-run-all -p ng:serve electron:live-reload", "build": "npm run build:src-main && ng build", "build:dev": "npm run build -- -c dev", "build:prod": "npm run build -- -c production", "build:src-main": "tsc -p tsconfig.src-main.json", "ng:serve": "ng serve -c production", - "electron:serve": "wait-on http-get://localhost:4200/ && npm run build:src-main && electron . --serve", + "electron:live-reload": "wait-on http-get://localhost:4200/ && npm run build:src-main && electron . --live-reload", "electron:local": "npm run build:prod && electron .", "electron-builder:linux": "npm run build:prod && electron-builder build --linux", "electron-builder:mac": "npm run build:prod && electron-builder build --mac", diff --git a/src-main/command-line-options/parse-command-line-options.ts b/src-main/command-line-options/parse-command-line-options.ts index 581973a1..cd7bf2e5 100644 --- a/src-main/command-line-options/parse-command-line-options.ts +++ b/src-main/command-line-options/parse-command-line-options.ts @@ -4,7 +4,7 @@ import { commandLineOptionsValue } from './command-line-options-value'; export function parseCommandLineOptions() { const program = new Command(); program - .addOption(new Option('--serve', 'launch the app in live-reload mode for development').hideHelp()) + .addOption(new Option('--live-reload', 'launch the app in live-reload mode for development').hideHelp()) .option('--open ', 'open the specified file or folder after the app is launched') .parse(process.argv, { from: 'electron' }); commandLineOptionsValue.set(program.opts()); diff --git a/src-main/live-reload.ts b/src-main/live-reload.ts index 512ae698..adbb2ab9 100644 --- a/src-main/live-reload.ts +++ b/src-main/live-reload.ts @@ -1,5 +1,5 @@ const args = process.argv.slice(1); -const isLiveReloadMode = args.some(val => val === '--serve'); +const isLiveReloadMode = args.some(val => val === '--live-reload'); export class LiveReload { public static get enabled() { return isLiveReloadMode; } diff --git a/src-main/record-at-app-launch.ts b/src-main/record-at-app-launch.ts index 14cd0801..f87cfe7a 100644 --- a/src-main/record-at-app-launch.ts +++ b/src-main/record-at-app-launch.ts @@ -22,7 +22,7 @@ const recordCommandLineOptions = () => { Logger.info(`process.argv:\n${toLoggableString(process.argv)}`); const options = commandLineOptionsValue.get(); Logger.info(`Parsed command line options:\n${toLoggableString(options)}`); - Analytics.trackEvent('Command Line Options', 'Command Line Options: "--serve"', `Is "--serve" set? -> ${!!options.serve}`); + Analytics.trackEvent('Command Line Options', 'Command Line Options: "--live-reload"', `Is "--live-reload" set? -> ${!!options.liveReload}`); Analytics.trackEvent('Command Line Options', 'Command Line Options: "--open "', `Is "--open " set? -> ${!!options.open}`); }; diff --git a/src-shared/command-line-options/command-line-options.ts b/src-shared/command-line-options/command-line-options.ts index 830ad3aa..d3f0aba1 100644 --- a/src-shared/command-line-options/command-line-options.ts +++ b/src-shared/command-line-options/command-line-options.ts @@ -1,4 +1,4 @@ export interface CommandLineOptions { - serve?: boolean; + liveReload?: boolean; open?: string; } From 12198ad0e3925d269a2855e484a33a37d2397ff6 Mon Sep 17 00:00:00 2001 From: Tomoyuki Aota Date: Mon, 2 Dec 2024 13:05:59 +0900 Subject: [PATCH 2/2] Determine live reload mode using CommandLineOptions object created by commander npm package. --- src-main/live-reload.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src-main/live-reload.ts b/src-main/live-reload.ts index adbb2ab9..f5c526d1 100644 --- a/src-main/live-reload.ts +++ b/src-main/live-reload.ts @@ -1,6 +1,5 @@ -const args = process.argv.slice(1); -const isLiveReloadMode = args.some(val => val === '--live-reload'); +import { commandLineOptionsValue } from './command-line-options/command-line-options-value'; export class LiveReload { - public static get enabled() { return isLiveReloadMode; } + public static get enabled() { return commandLineOptionsValue.get().liveReload; } }