t3-code-android-nightly/.repos/alchemy-effect/scripts/floci-image.ts
Julius Marminge e3c85ead63
chore(refs): sync Effect and Alchemy references to rc.115 and beta.78 (#12327)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-17 23:21:25 -07:00

28 lines
1.2 KiB
TypeScript

/**
* Point the floci-backed suites at a locally built emulator when one exists.
*
* `pnpm floci:build` tags the `submodules/floci` checkout as `floci:dev`;
* that is how an emulator patch gets exercised before its release image is
* published to GHCR. When no such image exists the env is left unset so the
* floci package resolves the pinned release image — hard-defaulting to a
* missing ref would fail every suite's `docker run` before a test can run.
*
* Must run before any child `bun test` is spawned: `ensureFloci` reads
* `ALCHEMY_FLOCI_IMAGE` in the child, and a container running a different
* image than the resolved one is recreated.
*/
export const preferLocalFlociImage = (label: string): void => {
if (process.env.ALCHEMY_FLOCI_IMAGE) return;
const devImage = Bun.spawnSync(["docker", "image", "inspect", "floci:dev"], {
stdout: "ignore",
stderr: "ignore",
});
if (devImage.exitCode === 0) {
process.env.ALCHEMY_FLOCI_IMAGE = "floci:dev";
console.log(`${label}: using locally built floci:dev image`);
} else {
console.log(
`${label}: no local floci:dev image (pnpm floci:build) — using the pinned release image`,
);
}
};