From dadb1a3fba3d1fa0d90d2130e73f7f198d6650c0 Mon Sep 17 00:00:00 2001 From: Reinier Criel Date: Mon, 3 Nov 2025 09:55:39 -0800 Subject: [PATCH] Adapt runPipCommand.js documentation --- .../src/packagemanager/pip/runPipCommand.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/safe-chain/src/packagemanager/pip/runPipCommand.js b/packages/safe-chain/src/packagemanager/pip/runPipCommand.js index 99ee97c..ce75466 100644 --- a/packages/safe-chain/src/packagemanager/pip/runPipCommand.js +++ b/packages/safe-chain/src/packagemanager/pip/runPipCommand.js @@ -6,10 +6,13 @@ import { getCombinedCaBundlePath } from "../../registryProxy/certBundle.js"; /** * @param {string} command * @param {string[]} args + * + * @returns {Promise<{status: number}>} */ export async function runPip(command, args) { try { - const env = mergeSafeChainProxyEnvironmentVariables(/** @type {Record} */ (process.env)); + // @ts-expect-error values of process.env can be string | undefined + const env = mergeSafeChainProxyEnvironmentVariables(process.env); // Always provide Python with a complete CA bundle (Safe Chain CA + Mozilla + Node built-in roots) // so that any network request made by pip, including those outside explicit CLI args, @@ -23,12 +26,11 @@ export async function runPip(command, args) { env, }); return { status: result.status }; - } catch (error) { - if (error && typeof error === "object" && "status" in error) { - return { status: /** @type {any} */ (error).status }; + } catch (/** @type any */ error) { + if (error.status) { + return { status: error.status }; } else { - const message = error && typeof error === "object" && "message" in error ? /** @type {any} */ (error).message : String(error); - ui.writeError("Error executing command:", message); + ui.writeError("Error executing command:", error.message); return { status: 1 }; } }