From 5aebed59ab00ed6027518e12a081ad39725858d4 Mon Sep 17 00:00:00 2001 From: frostebite Date: Wed, 26 Aug 2026 18:32:00 +0100 Subject: [PATCH] fix: avoid Array#toReversed() - unsupported on this project's target Node --- src/download-cli.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/download-cli.ts b/src/download-cli.ts index d4cf0c2a..222bc2da 100644 --- a/src/download-cli.ts +++ b/src/download-cli.ts @@ -162,12 +162,19 @@ export async function downloadCli(version: string): Promise { // install.sh writes progress to stderr and only the final binary path to // stdout, but take the last non-empty line regardless - defensive against - // any stray stdout noise from a future version of the script. - const binaryPath = stdout - .split('\n') - .map((line) => line.trim()) - .toReversed() - .find(Boolean); + // any stray stdout noise from a future version of the script. Walked + // backwards by index rather than toReversed()/reverse() - toReversed() + // isn't available on this project's target Node version, and reverse() + // mutates in place, which unicorn/no-array-reverse flags even when the + // array being mutated is a fresh one from map(). + 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) { throw new Error(