mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Adapt runPipCommand.js documentation
This commit is contained in:
parent
181470d764
commit
dadb1a3fba
1 changed files with 8 additions and 6 deletions
|
|
@ -6,10 +6,13 @@ import { getCombinedCaBundlePath } from "../../registryProxy/certBundle.js";
|
||||||
/**
|
/**
|
||||||
* @param {string} command
|
* @param {string} command
|
||||||
* @param {string[]} args
|
* @param {string[]} args
|
||||||
|
*
|
||||||
|
* @returns {Promise<{status: number}>}
|
||||||
*/
|
*/
|
||||||
export async function runPip(command, args) {
|
export async function runPip(command, args) {
|
||||||
try {
|
try {
|
||||||
const env = mergeSafeChainProxyEnvironmentVariables(/** @type {Record<string, string>} */ (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)
|
// 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,
|
// 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,
|
env,
|
||||||
});
|
});
|
||||||
return { status: result.status };
|
return { status: result.status };
|
||||||
} catch (error) {
|
} catch (/** @type any */ error) {
|
||||||
if (error && typeof error === "object" && "status" in error) {
|
if (error.status) {
|
||||||
return { status: /** @type {any} */ (error).status };
|
return { status: error.status };
|
||||||
} else {
|
} else {
|
||||||
const message = error && typeof error === "object" && "message" in error ? /** @type {any} */ (error).message : String(error);
|
ui.writeError("Error executing command:", error.message);
|
||||||
ui.writeError("Error executing command:", message);
|
|
||||||
return { status: 1 };
|
return { status: 1 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue