Skip to content

Commit

Permalink
fix: Read all argvs (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyaiox authored Sep 12, 2024
1 parent 9460d6a commit a330057
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"build:renderer": "cd ./packages/renderer && vite build",
"build:shared": "cd ./packages/shared && vite build",
"compile": "cross-env MODE=production npm run build && electron-builder build --config electron-builder.yml --dir",
"compile:installer": "cross-env MODE=production npm run build && electron-builder build --config electron-builder.yml",
"compile:installer": "cross-env MODE=production npm run build && electron-builder build --config electron-builder.yml --publish never",
"test": "npm run test:main && npm run test:preload && npm run test:renderer && npm run test:e2e",
"test:e2e": "npm run build && vitest run",
"test:main": "vitest run -r packages/main --passWithNoTests",
Expand Down
4 changes: 2 additions & 2 deletions packages/main/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ export function isAppUpdated(appPath: string, version: string): boolean {
export function getAdditionalArguments(): string[] {
const args = [];

if (process.argv.length > 2) {
for (let i = 2; i < process.argv.length; i++) {
if (process.argv.length > 0) {
for (let i = 0; i < process.argv.length; i++) {
const arg = process.argv[i];
if (/--(version|prerelease|dev|downloadedfilepath)/.test(arg)) {
args.push(arg);
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/modules/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export async function launchExplorer(event: Electron.IpcMainInvokeEvent, version

if (!fs.existsSync(explorerBinPath)) {
const errorMessage = version ? `The explorer version specified: ${version} is not installed.` : 'The explorer is not installed.';
log.error(`[Main Window][IPC][LaunchExplorer] ${errorMessage}`);
log.error(`[Main Window][IPC][LaunchExplorer] ${errorMessage}`, explorerBinPath);
event.sender.send(IPC_EVENTS.LAUNCH_EXPLORER, {
type: IPC_EVENT_DATA_TYPE.ERROR,
error: errorMessage,
Expand Down
4 changes: 2 additions & 2 deletions packages/main/src/modules/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export function initProtocol() {
}

app.whenReady().then(() => {
if (process.argv.length >= 2) {
const url = process.argv.slice(1).find(arg => arg.startsWith(`${PROTOCOL}://`));
if (process.argv.length > 0) {
const url = process.argv.find(arg => arg.startsWith(`${PROTOCOL}://`));
if (url) {
handleProtocol(url);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/preload/src/argvs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export function isValidVersion(version: string): boolean {
export function parseArgv(): Record<string, string> {
const parsedArgv: Record<string, string> = {};

if (process.argv.length > 2) {
for (let i = 2; i < process.argv.length; i++) {
if (process.argv.length > 0) {
for (let i = 0; i < process.argv.length; i++) {
const arg = process.argv[i];
if (/--(version|prerelease|dev|downloadedfilepath)/.test(arg)) {
const [key, value] = arg.split('=');
Expand Down

0 comments on commit a330057

Please sign in to comment.