mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 11:26:46 +00:00
19 lines
404 B
TypeScript
19 lines
404 B
TypeScript
export function captureEnv(keys: string[]) {
|
|
const snapshot = new Map<string, string | undefined>();
|
|
for (const key of keys) {
|
|
snapshot.set(key, process.env[key]);
|
|
}
|
|
|
|
return {
|
|
restore() {
|
|
for (const [key, value] of snapshot) {
|
|
if (value === undefined) {
|
|
delete process.env[key];
|
|
} else {
|
|
process.env[key] = value;
|
|
}
|
|
}
|
|
},
|
|
};
|
|
}
|