git-graft
Version:
NPX CLI tool that generates a configurable Git Hook that prepends branch name patterns to commit messages.
34 lines (33 loc) • 1.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = require("@oclif/command");
const path = require("path");
const fsp = require("fs/promises");
const accessCheck_1 = require("../accessCheck");
const chalk = require("chalk");
class Doctor extends command_1.Command {
async run() {
const { args, flags } = this.parse(Doctor);
try {
const pathToHook = path.join(process.cwd(), "./.git/hooks/commit-msg");
const actualPath = await fsp.realpath(pathToHook);
this.log("Directory should have 'commit-msg': ", await fsp.readdir(path.join(process.cwd(), "./.git/hooks/")));
this.log("Filepath: ", actualPath);
accessCheck_1.accessCheck(pathToHook);
}
catch (e) {
this.log(chalk.white("Error During Checks: "), chalk.red(e));
this.log(chalk.red("Re-Attempt Access change by passing in FilePath & --force"));
if (args.name && flags.force) {
accessCheck_1.accessCheck(args.name);
}
}
}
}
exports.default = Doctor;
Doctor.description = `"doctor" will run permission and other checks on the Git Graft Hook.`;
Doctor.flags = {
help: command_1.flags.help({ char: "h" }),
force: command_1.flags.boolean({ char: "f" }),
};
Doctor.args = [{ name: "file" }];