@ebuka_dev/git-branch-cleaner
Version:
A CLI tool to help manage and clean up Git branches
33 lines (32 loc) • 1.41 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.listAllBranches = listAllBranches;
const GitService_1 = require("../services/GitService");
const spinner_1 = require("../utils/spinner");
const console_1 = require("../utils/console");
const chalk_1 = __importDefault(require("chalk"));
async function listAllBranches() {
spinner_1.spinner.start("Fetching all branches...");
try {
const branches = await GitService_1.gitService.getAllBranches();
if (branches.all.length === 0) {
spinner_1.spinner.stop();
(0, console_1.logSuccess)("No branches found!");
return;
}
spinner_1.spinner.stop();
(0, console_1.logInfo)("All branches:");
Object.entries(branches.branches).forEach(([name, branch]) => {
const currentMarker = branch.current ? chalk_1.default.green("*") : " ";
const branchColor = branch.label.includes(": gone") ? chalk_1.default.red : chalk_1.default.gray;
console.log(` ${currentMarker} ${branchColor(name)}`);
});
}
catch (error) {
spinner_1.spinner.fail("Failed to fetch all branches!");
(0, console_1.logError)("Error fetching all branches:", error);
}
}