()
| 23 | } |
| 24 | |
| 25 | function main() { |
| 26 | const messageFilePath = process.argv[2]; |
| 27 | const commitSource = process.argv[3] || ''; |
| 28 | |
| 29 | if (!messageFilePath || SKIP_SOURCES.has(commitSource)) { |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | const original = fs.readFileSync(messageFilePath, 'utf8'); |
| 34 | const firstLine = getFirstMeaningfulLine(original); |
| 35 | if (firstLine) { |
| 36 | return; |
| 37 | } |
| 38 | |
| 39 | const commentLines = original |
| 40 | .split(/\r?\n/) |
| 41 | .filter(line => line.trim().startsWith('#')); |
| 42 | |
| 43 | const content = [ |
| 44 | TEMPLATE_HEADER, |
| 45 | '', |
| 46 | '# 格式: <emoji> <type>(optional-scope): <中文描述>', |
| 47 | '# 示例: 🐛 fix(simyo): 修复验证码重试逻辑', |
| 48 | ...commentLines |
| 49 | ].join('\n'); |
| 50 | |
| 51 | fs.writeFileSync(messageFilePath, content, 'utf8'); |
| 52 | } |
| 53 | |
| 54 | main(); |
no test coverage detected