UNPKG

git-command-helper

Version:
26 lines (23 loc) 774 B
// git-command-helper 2.1.0 by Dimas Lanjaka <dimaslanjaka@gmail.com> (https://www.webmanajemen.com) import { trueCasePathSync } from 'sbg-utility'; import path from 'upath'; import 'bluebird'; import 'cross-spawn'; import spawnAsync from '../dependencies/@expo/spawn-async/build/spawnAsync.mjs'; import 'lodash'; import 'stream'; /** * get root directory of local repository * * see {@link https://stackoverflow.com/a/957978} * @returns */ async function getGithubRootDir(opt = {}) { if (!opt.cwd) opt.cwd = process.cwd(); try { const result = await spawnAsync("git", ["rev-parse", "--show-toplevel"], opt); return path.toUnix(trueCasePathSync(result.stdout.trim())); } catch (err) { if (opt.throwable) throw err; } } export { getGithubRootDir };