Skip to content

Commit

Permalink
Merge pull request #572 from TomoyukiAota/feature/live-reload-mode-wi…
Browse files Browse the repository at this point in the history
…th-command-line-option

Rename the command line option from --serve to --live-reload. Determine live reload mode using CommandLineOptions object created by commander npm package.
  • Loading branch information
mergify[bot] authored Dec 2, 2024
2 parents f1f6675 + 12198ad commit d6bd864
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path>', 'open the specified file or folder after the app is launched')
.parse(process.argv, { from: 'electron' });
commandLineOptionsValue.set(program.opts());
Expand Down
5 changes: 2 additions & 3 deletions src-main/live-reload.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const args = process.argv.slice(1);
const isLiveReloadMode = args.some(val => val === '--serve');
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; }
}
2 changes: 1 addition & 1 deletion src-main/record-at-app-launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path>"', `Is "--open <path>" set? -> ${!!options.open}`);
};

Expand Down
2 changes: 1 addition & 1 deletion src-shared/command-line-options/command-line-options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface CommandLineOptions {
serve?: boolean;
liveReload?: boolean;
open?: string;
}

0 comments on commit d6bd864

Please sign in to comment.