UNPKG

git-command-helper

Version:
27 lines (24 loc) 808 B
// git-command-helper 2.1.0 by Dimas Lanjaka <dimaslanjaka@gmail.com> (https://www.webmanajemen.com) import _ from 'lodash'; import 'bluebird'; import 'cross-spawn'; import spawnAsync from '../dependencies/@expo/spawn-async/build/spawnAsync.mjs'; import 'stream'; import { safeURL } from '../utils/safe-url.mjs'; /** * get origin url * * see {@link https://stackoverflow.com/a/4090938} * @param name remote name in config, default `origin` * @returns */ async function getGithubRemote(name = "origin", opt = {}) { try { if (!name) name = "origin"; const result = await spawnAsync("git", `config --get remote.${name}.url`.split(" "), opt); return safeURL(result.stdout.trim()); } catch (err) { if (opt.throwable) throw err; return _.noop(err); } } export { getGithubRemote };