mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
test: reuse release env helper
This commit is contained in:
@@ -42,6 +42,7 @@ import {
|
||||
LOCAL_BUILD_METADATA_DIST_PATHS,
|
||||
PACKAGE_DIST_INVENTORY_RELATIVE_PATH,
|
||||
} from "../src/infra/package-dist-inventory.ts";
|
||||
import { withEnv } from "../src/test-utils/env.js";
|
||||
|
||||
function makeItem(shortVersion: string, sparkleVersion: string): string {
|
||||
return `<item><title>${shortVersion}</title><sparkle:shortVersionString>${shortVersion}</sparkle:shortVersionString><sparkle:version>${sparkleVersion}</sparkle:version></item>`;
|
||||
@@ -52,24 +53,7 @@ function makePackResult(filename: string, unpackedSize: number) {
|
||||
}
|
||||
|
||||
function withProcessEnv<T>(env: Record<string, string>, callback: () => T): T {
|
||||
const previous = new Map<string, string | undefined>();
|
||||
for (const key of Object.keys(env)) {
|
||||
previous.set(key, process.env[key]);
|
||||
}
|
||||
for (const [key, value] of Object.entries(env)) {
|
||||
process.env[key] = value;
|
||||
}
|
||||
try {
|
||||
return callback();
|
||||
} finally {
|
||||
for (const [key, value] of previous) {
|
||||
if (value === undefined) {
|
||||
delete process.env[key];
|
||||
} else {
|
||||
process.env[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return withEnv(env, callback);
|
||||
}
|
||||
|
||||
const requiredPluginSdkPackPaths = [...listPluginSdkDistArtifacts(), "dist/plugin-sdk/compat.js"];
|
||||
|
||||
Reference in New Issue
Block a user