Skip to content

Commit 4b0982c

Browse files
fix: safer electron version parsing for electron-builder command (#2673)
1 parent 9b15695 commit 4b0982c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

electron-app/scripts/package.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ const { isNightly, isRelease } = require('./utils');
66

77
async function run() {
88
/** @type {string} */
9-
const electronVersion =
9+
const rawElectronVersion =
1010
require('../package.json').devDependencies['electron'];
11+
const electronVersion = semver.clean(rawElectronVersion.replace(/^\^/, ''));
12+
if (!electronVersion) {
13+
throw new Error(
14+
`Electron semver validation failed for version: '${rawElectronVersion}'.`
15+
);
16+
}
1117
const platform = electronPlatform();
1218
const version = await getVersion();
1319
/** @type {string|unknown} */
@@ -18,7 +24,7 @@ async function run() {
1824
'--publish',
1925
'never',
2026
'-c.electronVersion',
21-
semver.clean(electronVersion.replace(/^\^/, '')),
27+
electronVersion,
2228
'-c.extraMetadata.version',
2329
version,
2430
// overrides the `name` in the `package.json` to keep the `localStorage` location. (https://github.com/arduino/arduino-ide/pull/2144#pullrequestreview-1554005028)

0 commit comments

Comments
 (0)