You can generate a Commit Template for creating commits messages easier.
$ node gitmoji.js > your/commit/template.txt
$ git config --global commit.template your/commit/template.txtYou can generate a Commit Template for creating commits messages easier.
$ node gitmoji.js > your/commit/template.txt
$ git config --global commit.template your/commit/template.txt| // Only if you are using Node.js | |
| const fetch = require("node-fetch"); | |
| async function main() { | |
| const res = await fetch( | |
| "https://raw.githubusercontent.com/carloscuesta/gitmoji/master/src/data/gitmojis.json" | |
| ); | |
| let { gitmojis } = await res.json(); | |
| gitmojis = gitmojis.sort((a, b) => | |
| a.code < b.code ? -1 : a.code > b.code ? 1 : 0 | |
| ); | |
| let longestCode = 0; | |
| let longestDescription = 0; | |
| for (const { code, description } of gitmojis) { | |
| if (code.length > longestCode) longestCode = code.length; | |
| if (description.length > longestDescription) | |
| longestDescription = description.length; | |
| } | |
| let lines = gitmojis.map( | |
| ({ emoji, code, description }) => | |
| ` ${emoji} ${code}${" ".repeat( | |
| longestCode - code.length | |
| )} ${description}` | |
| ); | |
| let longestLine = 0; | |
| for (const line of lines) { | |
| if (line.length > longestLine) longestLine = line.length; | |
| } | |
| const separator = "-".repeat(longestLine) + "--"; | |
| const file = [separator, "Gitmojis", separator, ...lines, separator] | |
| .map((l) => `# ${l}`) | |
| .join("\n"); | |
| console.log(file); | |
| } | |
| main(); |