fix: avoid Array#toReversed() - unsupported on this project's target Node

This commit is contained in:
frostebite
2026-08-26 18:32:00 +01:00
parent 8b0cc6cbd9
commit 5aebed59ab
+13 -6
View File
@@ -162,12 +162,19 @@ export async function downloadCli(version: string): Promise<string> {
// install.sh writes progress to stderr and only the final binary path to // install.sh writes progress to stderr and only the final binary path to
// stdout, but take the last non-empty line regardless - defensive against // stdout, but take the last non-empty line regardless - defensive against
// any stray stdout noise from a future version of the script. // any stray stdout noise from a future version of the script. Walked
const binaryPath = stdout // backwards by index rather than toReversed()/reverse() - toReversed()
.split('\n') // isn't available on this project's target Node version, and reverse()
.map((line) => line.trim()) // mutates in place, which unicorn/no-array-reverse flags even when the
.toReversed() // array being mutated is a fresh one from map().
.find(Boolean); const lines = stdout.split('\n').map((line) => line.trim());
let binaryPath: string | undefined;
for (let i = lines.length - 1; i >= 0; i -= 1) {
if (lines[i]) {
binaryPath = lines[i];
break;
}
}
if (!binaryPath) { if (!binaryPath) {
throw new Error( throw new Error(