Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 21x 21x 17x 21x 21x | import {isGenerated, type PrimitiveHost} from '../engine.ts';
/** Reading side of composition — the counterpart to `merge.ts`. */
/**
* The content of an existing file, but only when it is machine-generated.
*
* Merging into a hand-written file would be guesswork, so composition is limited
* to files that carry the generated marker; anything else is reported to the
* caller instead of silently rewritten.
*/
export function readGenerated(host: PrimitiveHost, root: string, path: string): string | undefined {
const absolute = host.join(root, path);
if (!host.existsSync(absolute)) return undefined;
const source = String(host.readFileSync(absolute, {encoding: 'utf-8'}));
return isGenerated(source) ? source : undefined;
}
|