branch-remover
Version:
A small application for quickly removing unnecessary branches from GitHub.
62 lines • 2.17 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.branchInfoFormatter = void 0;
const chalk_1 = __importDefault(require("chalk"));
const cli_table_1 = __importDefault(require("cli-table"));
const humanize_duration_1 = __importDefault(require("humanize-duration"));
const branchInfoFormatter = (branch) => {
var _a, _b, _c;
const now = new Date();
const table = new cli_table_1.default();
table.push({
'Branch': [
branch.name,
]
}, {
'State': [
branch.merged ? chalk_1.default.green('merged') : chalk_1.default.red('unmerged'),
]
}, {
'Merged date': [
branch.merged && branch.mergedDate
? humanize_duration_1.default(now.getTime() - branch.mergedDate.getTime(), {
largest: 1,
round: true,
}) + ` ago (${branch.mergedDate.toLocaleString()})`
: 'n/a',
]
}, {
'Updated date': [
humanize_duration_1.default(now.getTime() - ((_a = branch.updatedDate) === null || _a === void 0 ? void 0 : _a.getTime()), {
largest: 1,
round: true,
}) + ` ago (${(_b = branch.updatedDate) === null || _b === void 0 ? void 0 : _b.toLocaleString()})`,
]
}, {
'Has unmerged changes': [
branch.hasUncommittedChanges ? chalk_1.default.red('yes') : chalk_1.default.green('no'),
]
});
if (branch.url) {
table.push({
'Branch Url': [
branch.url,
]
});
}
if ((_c = branch.additionalInfo) === null || _c === void 0 ? void 0 : _c.size) {
branch.additionalInfo.forEach((value, key) => {
table.push({
[key]: [
value,
]
});
});
}
return table.toString();
};
exports.branchInfoFormatter = branchInfoFormatter;
//# sourceMappingURL=BranchInfoFormatter.js.map