All files / infrastructure/scripts/src/shared/adapters gh.ts

100% Statements 4/4
100% Branches 4/4
100% Functions 2/2
100% Lines 3/3

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    6x                   1x 6x                  
import { assertNotFlagLike, run } from "./exec.ts";
 
export const gh = (...args: string[]): string => run("gh", args);
 
interface NewIssue {
    title: string;
    body: string;
    label?: string;
    project?: string;
}
 
/** Use the locally authenticated `gh`; issue creation returns its URL. */
export const createIssue = ({ title, body, label, project }: NewIssue): string =>
    gh(
        "issue",
        "create",
        // The `=` form keeps a value starting with `-`, such as a markdown checklist, from reading as a flag.
        `--title=${title}`,
        `--body=${body}`,
        ...(label ? ["--label", assertNotFlagLike(label, "label")] : []),
        ...(project ? ["--project", assertNotFlagLike(project, "project")] : []),
    );