git-mob
Version:
CLI tool for adding co-authors to commits.
9 lines (8 loc) • 1.14 kB
JavaScript
import u from"minimist";import{Author as m,saveNewCoAuthors as l}from"git-mob-core";import{stripIndent as s}from"common-tags";import f from"update-notifier";var $=1e3*60*60*24*7;function e(){let o=s`
Usage
$ git add-coauthor <co-author-initials> "Coauthor Name" <coauthor-email-address>
Options
-h Prints usage information
Examples
$ git add-coauthor jd "John Doe" johndoe@aol.org # adds John Doe to coauthors file
`;console.log(o)}function r(o){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[(?:\d{1,3}\.){3}\d{1,3}])|((\w+\.)+[a-zA-Z]{2,}))$/.test(o)}var a={red:"\x1B[31m",yellow:"\x1B[33m"},n="\x1B[0m";function i(o){return a.red+o+n}var c=u(process.argv.slice(2),{alias:{h:"help"}});function h(o){if(o.length!==3)throw new Error("Incorrect number of parameters.");if(!r(o[2]))throw new Error("Invalid email format.");return new m(o[0],o[1],o[2])}async function g(o){if(o.help){e();return}let t=h(o._);await l([t]),console.log(t.name+" has been added to the .git-coauthors file")}await g(c).then(()=>{process.exit(0)}).catch(o=>{console.error(i(o.message)),process.exit(1)});