mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-11 21:59:38 +01:00
24 lines
1.0 KiB
JavaScript
24 lines
1.0 KiB
JavaScript
// The installed Codex dependency takes precedence over PATH. Pin only this
|
|
// acceptance server's command resolver to its deterministic protocol fixture.
|
|
import { accessSync, constants } from "node:fs";
|
|
import { registerHooks } from "node:module";
|
|
import { isAbsolute } from "node:path";
|
|
|
|
const command = process.env.PAPERCLIP_STOP_CODEX_COMMAND;
|
|
if (process.env.NODE_ENV !== "test" || !command || !isAbsolute(command)) {
|
|
throw new Error("Composer Stop requires an absolute fixture command in NODE_ENV=test");
|
|
}
|
|
accessSync(command, constants.X_OK);
|
|
registerHooks({
|
|
load(url, context, nextLoad) {
|
|
if (/(?:\/packages\/paperclip-runner\/(?:src|dist)|\/server\/(?:src|dist)\/vendor\/paperclip-runner)\/drivers\/codex\/codex-command\.(?:js|ts)$/.test(url)) {
|
|
return {
|
|
format: "module",
|
|
shortCircuit: true,
|
|
source: `export const resolveCodexCommand = () => ${JSON.stringify(command)}; export const resolvePinnedCodexCommand = resolveCodexCommand;`,
|
|
};
|
|
}
|
|
return nextLoad(url, context);
|
|
},
|
|
});
|