test: reuse release env helper

This commit is contained in:
Shakker
2026-06-05 01:06:55 +01:00
parent d6e1ca997b
commit 74680e3484

View File

@@ -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"];