()
| 76 | |
| 77 | /** Read the gitcode.com token from ~/.netrc, or null when absent/unreadable. */ |
| 78 | export function readNetrcToken(): string | null { |
| 79 | try { |
| 80 | const content = fs.readFileSync(netrcPath(), 'utf-8'); |
| 81 | const match = content.match( |
| 82 | new RegExp(`machine\\s+${GITCODE_HOST.replace('.', '\\.')}\\s+.*?password\\s+(\\S+)`), |
| 83 | ); |
| 84 | return match?.[1] ?? null; |
| 85 | } catch { |
| 86 | return null; |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Persist the token to ~/.netrc (mode 0600). Replaces any existing gitcode.com |
no test coverage detected