Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(tests): resolve the certificate banner's directory through createRequire

liuzixiangfb6d1b64e9fd
diff --git a/scripts/e2e-provider-certificates.mjs b/scripts/e2e-provider-certificates.mjs
index 2ee8ef939..03ab4fcac 100644
--- a/scripts/e2e-provider-certificates.mjs
+++ b/scripts/e2e-provider-certificates.mjs
@@ -67,8 +67,9 @@ process.stdout.write(JSON.stringify({jsonrpc:'2.0',method:'test.trust',params:{s
// Inject only the cjs interop the ESM bundle still needs. `dirname` and
// `fileURLToPath` stay out of the banner: the bundled main sources import
// them from `node:path` / `node:url` themselves, and a same-scope redeclare
- // is a syntax error.
- banner: { js: "import { createRequire as __piCreateRequire } from 'node:module'; const require = __piCreateRequire(import.meta.url); const __dirname = new URL('.', import.meta.url).pathname;" },
+ // is a syntax error. `__dirname` therefore resolves through the injected
+ // `createRequire` as well - `.pathname` is not a usable path on Windows.
+ banner: { js: "import { createRequire as __piCreateRequire } from 'node:module'; const require = __piCreateRequire(import.meta.url); const __dirname = __piCreateRequire('node:url').fileURLToPath(new URL('.', import.meta.url));" },
});
await run("localhost", "DEPTH_ZERO_SELF_SIGNED_CERT", false);
await run("localhost", "success", true);