Created
July 25, 2024 06:21
-
-
Save akm/0e58dc3908bdd768b393fb672b7496f4 to your computer and use it in GitHub Desktop.
Generate markdown table for emoji, code, English message and Japanese message from gitmoji-vscode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copy this file to the root directory of local directory from ttps://github.com/seatonjiang/gitmoji-vscode/ | |
const fs = require('fs'); | |
const jaDict = require('./languages/bundle.l10n.ja.json'); | |
const indexOfLineIncludes = (lines, s) => { | |
let idx = -1 | |
lines.forEach((line,i) => { if (line.includes(s)) idx = i }) | |
return idx | |
} | |
gitemojiSource = fs.readFileSync("src/gitmoji.ts", "utf8"); | |
gitemojiSourceLines = gitemojiSource.split("\n"); | |
let varIndex = indexOfLineIncludes(gitemojiSourceLines, "let Gitmoji"); | |
let exportIndex = indexOfLineIncludes(gitemojiSourceLines, "export default Gitmoji"); | |
lines = ["Gitmoji = [", ...gitemojiSourceLines.slice(varIndex+1, exportIndex)] | |
const vscode = { | |
l10n: { | |
t: (s) => [s, jaDict[s]] | |
} | |
} | |
eval(lines.join("\n")) | |
console.log("emoji | code | en | ja") | |
console.log("------|------|----|----") | |
for (let x of Gitmoji) { | |
console.log([x.emoji, '`'+ x.code + '`', ...x.description].join(" | ")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment