@temari/digitm
Version:
git commit 规范的 表情emoji 的提交
54 lines (53 loc) • 2.66 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 });
/*
* @Author: saber
* @Date: 2021-12-27 19:47:58
* @LastEditTime: 2021-12-27 20:08:42
* @LastEditors: saber
* @Description:
*/
const execa_1 = __importDefault(require("execa"));
// import fs from 'fs'
const chalk_1 = __importDefault(require("chalk"));
// import isHookCreated from '../../../utils/isHookCreated'
// import configurationVault from '../../../utils/configurationVault'
const withClient = (answers) => __awaiter(void 0, void 0, void 0, function* () {
try {
const scope = answers.scope ? `(${answers.scope}): ` : '';
const title = `${answers.gitmoji} ${scope}${answers.title}`;
// const isSigned = configurationVault.getSignedCommit() ? ['-S'] : []
const isSigned = [];
// if (await isHookCreated()) {
// return console.log(
// chalk.red(
// "\nError: Seems that you're trying to commit with the cli " +
// 'but you have the hook created.\nIf you want to use the `gitmoji -c` ' +
// 'command you have to remove the hook with the command `gitmoji -r`. \n' +
// 'The hook must be used only when you want to commit with the instruction `git commit`\n'
// )
// )
// }
// if (configurationVault.getAutoAdd()) await execa('git', ['add', '.'])
yield (0, execa_1.default)('git', ['commit', ...isSigned, '-m', title, '-m', answers.message], {
buffer: false,
stdio: 'inherit'
});
}
catch (error) {
console.error(chalk_1.default.red('\n', 'Oops! An error ocurred. There is likely additional logging output above.\n', 'You can run the same commit with this command:\n'), '\t', error.escapedCommand);
}
});
exports.default = withClient;