git-command-helper
Version:
github command helper for nodejs
27 lines (24 loc) • 801 B
JavaScript
// 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';
/**
* get current branch informations
* @returns
*/
async function getGithubBranches(opt = {}) {
try {
const result = await spawnAsync("git", ["branch"], opt);
return result.stdout.trim().split(/\n/).map(str => str.split(/\s/).map(str_1 => str_1.trim())).filter(str_2 => str_2.length > 0).map(item => {
return {
active: item.length > 1,
branch: item[1]
};
}).filter(item_1 => typeof item_1.branch === "string");
} catch (err) {
return _.noop(err);
}
}
export { getGithubBranches };