Documentation for Simbo's Packages
    Preparing search index...

    Interface GitFixture

    A temporary Git repository for tests.

    Remove it with cleanup(), or declare it with await using to remove it at the end of the scope.

    interface GitFixture {
        cleanup: () => Promise<void>;
        commit: (
            message: string,
            files?: Readonly<Record<string, string | Uint8Array<ArrayBufferLike>>>,
        ) => Promise<string>;
        dir: string;
        env: Readonly<Record<string, string>>;
        git: (args: readonly string[]) => Promise<string>;
        gitSucceeds: (args: readonly string[]) => Promise<boolean>;
        path: (...segments: string[]) => string;
        write: (
            path: string,
            contents: string | Uint8Array<ArrayBufferLike>,
        ) => Promise<void>;
        writeFiles: (files: GitFixtureFiles) => Promise<void>;
        "[asyncDispose]"(): PromiseLike<void>;
    }

    Hierarchy

    • AsyncDisposable
      • GitFixture
    Index
    cleanup: () => Promise<void>

    Removes the repository directory.

    commit: (
        message: string,
        files?: Readonly<Record<string, string | Uint8Array<ArrayBufferLike>>>,
    ) => Promise<string>

    Writes the files, stages all changes, and commits them. Without changes, the commit is empty.

    Type Declaration

      • (
            message: string,
            files?: Readonly<Record<string, string | Uint8Array<ArrayBufferLike>>>,
        ): Promise<string>
      • Parameters

        • message: string

          The commit message.

        • Optionalfiles: Readonly<Record<string, string | Uint8Array<ArrayBufferLike>>>

          Files to write before committing.

        Returns Promise<string>

        The hash of the new commit.

    if the commit fails.

    dir: string

    The absolute path of the repository, with symbolic links resolved.

    env: Readonly<Record<string, string>>

    The environment variables of the neutral configuration. Set them for the code under test, so that it runs Git like the fixture.

    git: (args: readonly string[]) => Promise<string>

    Runs a Git command in the repository with the neutral configuration.

    Type Declaration

      • (args: readonly string[]): Promise<string>
      • Parameters

        • args: readonly string[]

          The Git arguments.

        Returns Promise<string>

        The trimmed standard output.

    if the command fails.

    gitSucceeds: (args: readonly string[]) => Promise<boolean>

    Runs a Git command in the repository with the neutral configuration and reports whether it exited with code 0.

    Type Declaration

      • (args: readonly string[]): Promise<boolean>
      • Parameters

        • args: readonly string[]

          The Git arguments.

        Returns Promise<boolean>

        true if the command exited with code 0, otherwise false.

    if Git cannot run.

    path: (...segments: string[]) => string

    Resolves a path in the repository.

    Type Declaration

      • (...segments: string[]): string
      • Parameters

        • ...segments: string[]

          Path segments relative to the repository root.

        Returns string

        The absolute path.

    write: (
        path: string,
        contents: string | Uint8Array<ArrayBufferLike>,
    ) => Promise<void>

    Writes a file in the repository without staging it, creating parent directories as needed.

    Type Declaration

      • (path: string, contents: string | Uint8Array<ArrayBufferLike>): Promise<void>
      • Parameters

        • path: string

          The file path relative to the repository root.

        • contents: string | Uint8Array<ArrayBufferLike>

          The file contents.

        Returns Promise<void>

    if the path is outside the repository, also through symbolic links.

    writeFiles: (files: GitFixtureFiles) => Promise<void>

    Writes several files in the repository without staging them.

    Type Declaration

    if a path is outside the repository, also through symbolic links.

    • Returns PromiseLike<void>