gitsu-cli
Version:
Interactive command line util for quickly & easily switching git users
32 lines (31 loc) • 1.76 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_child_process_1 = __importDefault(require("node:child_process"));
const chalk_1 = __importDefault(require("chalk"));
const log_symbols_1 = __importDefault(require("log-symbols"));
const choice_1 = require("../utils/choice");
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
try {
const gitUserEmail = yield node_child_process_1.default.execSync('git config user.email');
const email = gitUserEmail.toString().trim();
const gitUserName = yield node_child_process_1.default.execSync('git config user.name');
const name = gitUserName.toString().trim();
return (0, choice_1.formatChoice)({ name, email });
}
catch (error) {
console.error(`${log_symbols_1.default.error} ${chalk_1.default.red('Failed to fetch current git identity')}`, error);
return '';
}
});