git-command-helper
Version:
github command helper for nodejs
29 lines (25 loc) • 844 B
JavaScript
// git-command-helper 2.1.0 by Dimas Lanjaka <dimaslanjaka@gmail.com> (https://www.webmanajemen.com)
;
var _ = require('lodash');
require('bluebird');
require('cross-spawn');
var spawnAsync = require('../dependencies/@expo/spawn-async/build/spawnAsync.js');
require('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);
}
}
exports.getGithubBranches = getGithubBranches;