| 44 | } |
| 45 | |
| 46 | export function validateEmail(email) { |
| 47 | if (!email) { |
| 48 | log('ERROR', '缺少 -email 参数') |
| 49 | log('ERROR', '用法: node script.js -email you@example.com') |
| 50 | process.exit(1) |
| 51 | } |
| 52 | |
| 53 | if (typeof email !== 'string') { |
| 54 | log('ERROR', `无效的邮箱类型: 期望是字符串, 实际得到 ${typeof email}`) |
| 55 | log('ERROR', '用法: node script.js -email you@example.com') |
| 56 | process.exit(1) |
| 57 | } |
| 58 | |
| 59 | if (!email.includes('@')) { |
| 60 | log('ERROR', `无效的邮箱格式: "${email}"`) |
| 61 | log('ERROR', '邮箱必须包含 "@" 符号') |
| 62 | log('ERROR', '示例: you@example.com') |
| 63 | process.exit(1) |
| 64 | } |
| 65 | |
| 66 | return email |
| 67 | } |
| 68 | |
| 69 | export function loadJsonFile(possiblePaths, required = true) { |
| 70 | for (const filePath of possiblePaths) { |