mirror of
https://github.com/block/buzz.git
synced 2026-10-29 13:31:44 +00:00
12 lines
704 B
TypeScript
12 lines
704 B
TypeScript
// Test-only module instrumentation: execute the real CLI, inject only the existing
|
|
// storage boundary. No production environment switch or copied shutdown owner.
|
|
import { registerHooks } from 'node:module';
|
|
registerHooks({ load(url, context, nextLoad) {
|
|
const loaded = nextLoad(url, context);
|
|
if (!url.endsWith('/src/relay.ts')) return loaded;
|
|
const source = String(loaded.source);
|
|
const needle = 'boundary?: SnapshotBoundary';
|
|
if (!source.includes(needle)) throw Error('Relay boundary instrumentation drift');
|
|
return { ...loaded, source: source.replace(needle, "boundary: SnapshotBoundary = async phase => { if (phase === 'directory') throw Error('injected directory fault'); }") };
|
|
} });
|