Module
helps manage and harmonise READMEs in many repositories with template files
Latest
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121import { runCommand } from "./utils.ts";
/** * Attempt to find the repository remote url. * Silently fails. * * ```ts * import { getRepository } from "./git.ts" * const url = await getRepository('/path/to/git/repo', (errorMsg: string, error?: Error) => {}) * ``` * * @param {string} directory The path of the git directory. * @param {function(string, Error)} error Handler for errors. */export const getRepository = ( directory: string, error: (message: string, error?: Error) => void,) => { return runCommand( [ "git", "-C", directory, "config", "--get", "remote.origin.url", ], error, true, );};
/** * Attempt to find the current repos git tag. * Silently fails. * * ```ts * import { getTag } from "./git.ts" * const tag = await getTag('/path/to/git/repo', (errorMsg: string, error?: Error) => {}) * ``` * * @param {string} directory The path of the git directory. * @param {function(string, Error)} error Handler for errors. */export const getTag = ( directory: string, error: (message: string, error?: Error) => void,) => { return runCommand( [ "git", "-C", directory, "describe", "--tags", "--abbrev=0", ], error, true, );};
/** * Attempt to find the current git branch. * Silently fails. * * ```ts * import { getBranch } from "./git.ts" * const branch = await getBranch('/path/to/git/repo', (errorMsg: string, error?: Error) => {}) * ``` * * @param {string} directory The path of the git directory. * @param {function(string, Error)} error Handler for errors. */export const getBranch = ( directory: string, error: (message: string, error?: Error) => void,) => { return runCommand( [ "git", "-C", directory, "rev-parse", "--abbrev-ref", "HEAD", ], error, true, );};
/** * Attempt to find the current git commit sha. * Silently fails. * * ```ts * import { getCommit } from "./git.ts" * const commit = await getCommit('/path/to/git/repo', (errorMsg: string, error?: Error) => {}) * ``` * * @param {string} directory The path of the git directory. * @param {function(string, Error)} error Handler for errors. */export const getCommit = ( directory: string, error: (message: string, error?: Error) => void,) => { return runCommand( [ "git", "-C", directory, "rev-parse", "HEAD", ], error, true, );};