From 6318b462bf7a3099f5a4924544028d4658274fd0 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 25 Jun 2026 14:57:20 +0000 Subject: [PATCH] fix: keep app-version and related args as strings in CLI parser yargs-parser was coercing numeric-looking values for app-version, build-version and app-copyright into JS numbers (e.g. --app-version 1.0 became the number 1). This failed the `typeof opts.appVersion === 'string'` check in src/packager.ts and threw the generic "Invalid processed options" error. Add these flags to the yargs `string:` allow-list so they are never coerced, plus a regression test asserting they stay strings. Fixes #1853. --- src/cli.ts | 2 +- test/cli.spec.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/cli.ts b/src/cli.ts index 9e34d546..fb9e6ebe 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -25,7 +25,7 @@ export function parseArgs(argv: string[]) { prune: true, tmpdir: true, }, - string: ['electron-version', 'out'], + string: ['app-copyright', 'app-version', 'build-version', 'electron-version', 'out'], }); args.dir = args._[0]; diff --git a/test/cli.spec.ts b/test/cli.spec.ts index 78f53212..45c06b00 100644 --- a/test/cli.spec.ts +++ b/test/cli.spec.ts @@ -9,6 +9,23 @@ describe('parseArgs', () => { expect(argsWithVersion.electronVersion).toBe('1.2.3'); }); + it('keeps numeric-looking version/copyright args as strings', () => { + const args = parseArgs([ + '--app-version', + '1.0', + '--build-version', + '2.0', + '--app-copyright', + '3.0', + ]); + expect(args.appVersion).toBe('1.0'); + expect(typeof args.appVersion).toBe('string'); + expect(args.buildVersion).toBe('2.0'); + expect(typeof args.buildVersion).toBe('string'); + expect(args.appCopyright).toBe('3.0'); + expect(typeof args.appCopyright).toBe('string'); + }); + it('populates opts.asar', () => { const args = parseArgs(['--asar=true']); expect(args.asar).toBe(true);