UNPKG

@rushstack/heft

Version:

Build all your JavaScript projects the same way: A way that works.

52 lines 1.93 kB
import { type GitRepoInfo as IGitRepoInfo } from 'git-repo-info'; export interface IGitVersion { major: number; minor: number; patch: number; } export type GitignoreFilterFn = (filePath: string) => boolean; export declare class GitUtilities { private readonly _workingDirectory; private _ignoreMatcherByGitignoreFolder; private _gitPath; private _gitInfo; private _gitVersion; constructor(workingDirectory: string); /** * Returns the path to the Git binary if found. Otherwise, return undefined. */ get gitPath(): string | undefined; /** * Get information about the current Git working tree. * Returns undefined if the current path is not under a Git working tree. */ getGitInfo(): Readonly<IGitRepoInfo> | undefined; /** * Gets the Git version and returns it. */ getGitVersion(): IGitVersion | undefined; /** * Returns true if the Git binary can be found. */ isGitPresent(): boolean; /** * Returns true if the Git binary was found and the current path is under a Git working tree. * @param repoInfo - If provided, do the check based on this Git repo info. If not provided, * the result of `this.getGitInfo()` is used. */ isPathUnderGitWorkingTree(repoInfo?: IGitRepoInfo): boolean; /** * Returns an asynchronous filter function which can be used to filter out files that are ignored by Git. */ tryCreateGitignoreFilterAsync(): Promise<GitignoreFilterFn | undefined>; private _findIgnoreMatcherForFilePath; private _getIgnoreMatchersAsync; private _tryReadGitIgnoreFileAsync; private _findUnignoredFilesAsync; private _executeGitCommandAndCaptureOutputAsync; private _getGitPathOrThrow; private _ensureGitMinimumVersion; private _ensurePathIsUnderGitWorkingTree; private _parseGitVersion; } //# sourceMappingURL=GitUtilities.d.ts.map