All files / core/blong-kukum/orchestrator/kukum sourceGet.ts

89.47% Statements 17/19
66.66% Branches 2/3
100% Functions 1/1
89.47% Lines 17/19

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 19 201x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 1x     1x 1x 1x  
import {library} from '@feasibleone/blong';
import {readSource} from '../../engine.ts';
import type {KukumLibContext, OperationParams} from '../../operation.ts';
 
/**
 * `kukum.source.get` — a file's source plus its embedded agent instructions.
 *
 * `generated` reports whether the file carries kukum's marker, which is what the
 * merge engine keys on.
 */
export default library(
    () =>
        function sourceGet(this: KukumLibContext, params: OperationParams) {
            if (!params.path) throw new Error('source.get requires a `path`');
            const host = this.platform;
            const root = host.resolve(params.target ?? '.');
            return readSource(host, root, params.path);
        },
);