mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
fix(process): apply undefined env removals (#107258)
Co-authored-by: Pavan Kumar Gondhi <pavangondhi@gmail.com>
This commit is contained in:
committed by
GitHub
parent
4974750614
commit
489690fa16
@@ -12,9 +12,6 @@ function assignChildEnvValue(params: {
|
||||
platform: NodeJS.Platform;
|
||||
value: string | undefined;
|
||||
}): void {
|
||||
if (params.value === undefined) {
|
||||
return;
|
||||
}
|
||||
if (params.platform === "win32") {
|
||||
const normalizedKey = params.key.toLowerCase();
|
||||
for (const existingKey of Object.keys(params.env)) {
|
||||
@@ -23,6 +20,10 @@ function assignChildEnvValue(params: {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (params.value === undefined) {
|
||||
delete params.env[params.key];
|
||||
return;
|
||||
}
|
||||
params.env[params.key] = params.value;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,42 +17,6 @@ export type { SpawnResult } from "./exec-result.js";
|
||||
export { resolveCommandEnv, shouldSpawnWithShell, spawnCommand } from "./exec-spawn.js";
|
||||
export type { SpawnCommandOptions } from "./exec-spawn.js";
|
||||
|
||||
function assignChildEnvValue(params: {
|
||||
env: NodeJS.ProcessEnv;
|
||||
key: string;
|
||||
platform: NodeJS.Platform;
|
||||
value: string | undefined;
|
||||
}): void {
|
||||
if (params.platform === "win32") {
|
||||
const normalizedKey = params.key.toLowerCase();
|
||||
for (const existingKey of Object.keys(params.env)) {
|
||||
if (existingKey.toLowerCase() === normalizedKey && existingKey !== params.key) {
|
||||
delete params.env[existingKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (params.value === undefined) {
|
||||
delete params.env[params.key];
|
||||
return;
|
||||
}
|
||||
params.env[params.key] = params.value;
|
||||
}
|
||||
|
||||
function mergeChildEnv(params: {
|
||||
baseEnv: NodeJS.ProcessEnv;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
platform: NodeJS.Platform;
|
||||
}): NodeJS.ProcessEnv {
|
||||
const resolvedEnv: NodeJS.ProcessEnv = {};
|
||||
for (const [key, value] of Object.entries(params.baseEnv)) {
|
||||
assignChildEnvValue({ env: resolvedEnv, key, platform: params.platform, value });
|
||||
}
|
||||
for (const [key, value] of Object.entries(params.env ?? {})) {
|
||||
assignChildEnvValue({ env: resolvedEnv, key, platform: params.platform, value });
|
||||
}
|
||||
return resolvedEnv;
|
||||
}
|
||||
|
||||
const DEFAULT_EXEC_MAX_BUFFER_BYTES = 1024 * 1024;
|
||||
|
||||
export type RunExecOptions = {
|
||||
|
||||
Reference in New Issue
Block a user