mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:30:47 +00:00
Update Corepack prompt handling
This commit is contained in:
committed by
Onur Solmaz
parent
766954d9a1
commit
a32c4e43b4
@@ -11,6 +11,7 @@ import {
|
||||
cleanupGlobalRenameDirs,
|
||||
detectGlobalInstallManagerByPresence,
|
||||
detectGlobalInstallManagerForRoot,
|
||||
createGlobalInstallEnv,
|
||||
globalInstallArgs,
|
||||
globalInstallFallbackArgs,
|
||||
isExplicitPackageInstallSpec,
|
||||
@@ -89,6 +90,20 @@ describe("update global helpers", () => {
|
||||
).toBe("https://example.com/openclaw-main.tgz");
|
||||
});
|
||||
|
||||
it("defaults corepack download prompts off for global install env", async () => {
|
||||
await expect(createGlobalInstallEnv({})).resolves.toMatchObject({
|
||||
COREPACK_ENABLE_DOWNLOAD_PROMPT: "0",
|
||||
});
|
||||
|
||||
await expect(
|
||||
createGlobalInstallEnv({
|
||||
COREPACK_ENABLE_DOWNLOAD_PROMPT: "1",
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
COREPACK_ENABLE_DOWNLOAD_PROMPT: "1",
|
||||
});
|
||||
});
|
||||
|
||||
it("classifies main and raw install specs separately from registry selectors", () => {
|
||||
expect(isMainPackageTarget("main")).toBe(true);
|
||||
expect(isMainPackageTarget(" MAIN ")).toBe(true);
|
||||
|
||||
@@ -29,6 +29,7 @@ const PRIMARY_PACKAGE_NAME = "openclaw";
|
||||
const ALL_PACKAGE_NAMES = [PRIMARY_PACKAGE_NAME] as const;
|
||||
const GLOBAL_RENAME_PREFIX = ".";
|
||||
export const OPENCLAW_MAIN_PACKAGE_SPEC = "github:openclaw/openclaw#main";
|
||||
const COREPACK_ENABLE_DOWNLOAD_PROMPT_DEFAULT = "0";
|
||||
const NPM_GLOBAL_INSTALL_QUIET_FLAGS = ["--no-fund", "--no-audit", "--loglevel=error"] as const;
|
||||
const NPM_GLOBAL_INSTALL_OMIT_OPTIONAL_FLAGS = [
|
||||
"--omit=optional",
|
||||
@@ -140,6 +141,13 @@ function applyWindowsPackageInstallEnv(env: Record<string, string>) {
|
||||
env.NODE_LLAMA_CPP_SKIP_DOWNLOAD = "1";
|
||||
}
|
||||
|
||||
function applyCorepackDownloadPromptEnv(env: Record<string, string>) {
|
||||
const current = env.COREPACK_ENABLE_DOWNLOAD_PROMPT?.trim();
|
||||
if (!current) {
|
||||
env.COREPACK_ENABLE_DOWNLOAD_PROMPT = COREPACK_ENABLE_DOWNLOAD_PROMPT_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveGlobalInstallSpec(params: {
|
||||
packageName: string;
|
||||
tag: string;
|
||||
@@ -165,9 +173,6 @@ export async function createGlobalInstallEnv(
|
||||
env?: NodeJS.ProcessEnv,
|
||||
): Promise<NodeJS.ProcessEnv | undefined> {
|
||||
const pathPrepend = await resolvePortableGitPathPrepend(env);
|
||||
if (pathPrepend.length === 0 && process.platform !== "win32") {
|
||||
return env;
|
||||
}
|
||||
const merged = Object.fromEntries(
|
||||
Object.entries(env ?? process.env)
|
||||
.filter(([, value]) => value != null)
|
||||
@@ -175,6 +180,7 @@ export async function createGlobalInstallEnv(
|
||||
) as Record<string, string>;
|
||||
applyPathPrepend(merged, pathPrepend);
|
||||
applyWindowsPackageInstallEnv(merged);
|
||||
applyCorepackDownloadPromptEnv(merged);
|
||||
return merged;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user