From 9563b5f98bf6ac5a00a0f9da6fcb5f34e89e1207 Mon Sep 17 00:00:00 2001 From: David Sanders Date: Thu, 6 Apr 2023 11:03:14 -0700 Subject: [PATCH] test: support 'latest'/'latest@X' Electron version strings (#37840) --- script/spec-runner.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/script/spec-runner.js b/script/spec-runner.js index a6f7083b7f07..8edc5d44d266 100755 --- a/script/spec-runner.js +++ b/script/spec-runner.js @@ -64,10 +64,24 @@ if (args.runners !== undefined) { async function main () { if (args.electronVersion) { const versions = await ElectronVersions.create(); - if (!versions.isVersion(args.electronVersion)) { + if (args.electronVersion === 'latest') { + args.electronVersion = versions.latest.version; + } else if (args.electronVersion.startsWith('latest@')) { + const majorVersion = parseInt(args.electronVersion.slice('latest@'.length)); + const ver = versions.inMajor(majorVersion).slice(-1)[0]; + if (ver) { + args.electronVersion = ver.version; + } else { + console.log(`${fail} '${majorVersion}' is not a recognized Electron major version`); + process.exit(1); + } + } else if (!versions.isVersion(args.electronVersion)) { console.log(`${fail} '${args.electronVersion}' is not a recognized Electron version`); process.exit(1); } + + const versionString = `v${args.electronVersion}`; + console.log(`Running against Electron ${versionString.green}`); } const [lastSpecHash, lastSpecInstallHash] = loadLastSpecHash();