mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-22 05:59:31 +08:00
* Add Node 24 environment-file support * Update runtime harnesses for environment-file URL paths * Link URL dependencies in weak metadata runtime tests
23 lines
943 B
TypeScript
23 lines
943 B
TypeScript
import { loadEnvFile } from "node:process";
|
|
import { URL } from "node:url";
|
|
|
|
function report(fn: () => unknown): void {
|
|
try { console.log("result", fn()); }
|
|
catch (error) {
|
|
if (error instanceof Error) console.log(error.name, (error as Error & { code?: string }).code ?? "", error.message);
|
|
}
|
|
}
|
|
report(() => loadEnvFile(42 as unknown as string));
|
|
report(() => loadEnvFile(false as unknown as string));
|
|
report(() => loadEnvFile({} as unknown as string));
|
|
report(() => loadEnvFile([] as unknown as string));
|
|
report(() => loadEnvFile(Symbol("path") as unknown as string));
|
|
report(() => loadEnvFile("a\0b"));
|
|
report(() => loadEnvFile(Buffer.from("a\0b")));
|
|
report(() => loadEnvFile(new Uint8Array([97, 0, 98])));
|
|
report(() => loadEnvFile(new URL("https://example.com/")));
|
|
report(() => loadEnvFile(new URL("file:///tmp/a%2fb")));
|
|
report(() => loadEnvFile("scriptc-env-missing"));
|
|
report(() => loadEnvFile("."));
|
|
console.log("recovered");
|