@tapjs/node-serialize
Version:
Stream TAP test data as a serialized node:test stream
19 lines • 690 B
JavaScript
import { locFromAt } from './loc-from-at.js';
export const serializeStdio = (stream, process, which) => {
const write = (m) => {
const message = String(m);
stream[which]({ ...locFromAt(write), message });
};
const orig = process[which];
Object.defineProperty(process, which, {
configurable: true,
enumerable: true,
writable: true,
// create a new object that inherits from the original, but has
// a write() method that captures a test:stderr/test:stdout message
value: Object.defineProperties(Object.create(orig), {
write: { value: write },
}),
});
};
//# sourceMappingURL=stdio.js.map