From 24c7ef049301173bfae9cf0165c3fa24d29bb616 Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Sat, 7 Dec 2024 05:15:08 +0900 Subject: [PATCH] Filter installable system dependencies correctly Signed-off-by: Sora Morimoto --- dist/index.js | 11 +++++++++-- packages/setup-ocaml/src/unix.ts | 13 +++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/dist/index.js b/dist/index.js index 59e134b2..5e1657ed 100644 --- a/dist/index.js +++ b/dist/index.js @@ -147263,12 +147263,19 @@ async function checkAptInstallability(packageName) { "--names-only", `'^${packageName}$'`, ]); - return output.stdout.length !== 0; + return output.stdout.length > 0; } async function retrieveInstallableOptionalDependencies(optionalDependencies) { switch (PLATFORM) { case "linux": { - return optionalDependencies.filter(async (dep) => await checkAptInstallability(dep)); + const installableOptionalDependencies = []; + for (const optionalDependency of optionalDependencies) { + const isInstallable = await checkAptInstallability(optionalDependency); + if (isInstallable) { + installableOptionalDependencies.push(optionalDependency); + } + } + return installableOptionalDependencies; } default: { return []; diff --git a/packages/setup-ocaml/src/unix.ts b/packages/setup-ocaml/src/unix.ts index 8a7a1d9f..abb58704 100644 --- a/packages/setup-ocaml/src/unix.ts +++ b/packages/setup-ocaml/src/unix.ts @@ -9,7 +9,7 @@ async function checkAptInstallability(packageName: string) { "--names-only", `'^${packageName}$'`, ]); - return output.stdout.length !== 0; + return output.stdout.length > 0; } async function retrieveInstallableOptionalDependencies( @@ -17,9 +17,14 @@ async function retrieveInstallableOptionalDependencies( ) { switch (PLATFORM) { case "linux": { - return optionalDependencies.filter( - async (dep) => await checkAptInstallability(dep), - ); + const installableOptionalDependencies: string[] = []; + for (const optionalDependency of optionalDependencies) { + const isInstallable = await checkAptInstallability(optionalDependency); + if (isInstallable) { + installableOptionalDependencies.push(optionalDependency); + } + } + return installableOptionalDependencies; } default: { return [];