Skip to content

Instantly share code, notes, and snippets.

@akm
Created July 25, 2024 06:21
Show Gist options
  • Save akm/0e58dc3908bdd768b393fb672b7496f4 to your computer and use it in GitHub Desktop.
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
// 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