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

89.65% Statements 26/29
33.33% Branches 2/6
100% Functions 1/1
89.65% Lines 26/29

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 20 21 22 23 24 25 26 27 28 29 301x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 2x 2x 2x 2x       2x 2x 2x 2x 2x 2x 2x 2x 2x 1x  
import {library} from '@feasibleone/blong';
import {diagnoseFor, type KukumLibContext, type OperationParams} from '../../operation.ts';
 
/**
 * `kukum.source.check` — lint given files, or the whole target package.
 *
 * Naming files scopes the run to them; naming none lints the package, which is
 * the cheap "did I break anything" question after a scaffold.
 */
export default library(
    () =>
        async function sourceCheck(this: KukumLibContext, params: OperationParams) {
            const host = this.platform;
            const root = host.resolve(params.target ?? '.');
            const files = params.files?.length
                ? params.files
                : params.path
                  ? [params.path]
                  : ['**/*.ts', '**/*.tsx', '**/*.md'];
            const scoped = params.files?.length || params.path;
            const diagnostics = await diagnoseFor(
                host,
                root,
                files,
                scoped ? 'changed' : 'package',
            );
            return {target: root, files, diagnostics};
        },
);