@cliz/gpm
Version:
Git Project Manager
20 lines (19 loc) • 849 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const cli_1 = require("@cliz/cli");
const path = require("path");
const parseGitUrl = require("git-url-parse");
const open = require("open");
exports.default = (0, cli_1.defineSubCommand)((createCommand, { api }) => {
return createCommand('Project GitHub Open').action(async () => {
const gitConfigPath = path.resolve(process.cwd(), '.git/config');
if (!api.fs.exist(gitConfigPath)) {
throw new Error(`Not a vaild git project`);
}
const gitConfig = await api.fs.ini.load(gitConfigPath);
const _url = gitConfig['remote "origin"'].url;
const _parsed = parseGitUrl(_url);
const url = `https://${_parsed.resource || _parsed.source}/${_parsed.owner}/${_parsed.name}`;
await open(url);
});
});