MCPcopy Create free account
hub / github.com/Tencent/teamai-cli / readNetrcToken

Function readNetrcToken

src/providers/gitcode/gitcode-api.ts:78–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

76
77/** Read the gitcode.com token from ~/.netrc, or null when absent/unreadable. */
78export 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

Callers 1

getGitCodeTokenFunction · 0.85

Calls 1

netrcPathFunction · 0.85

Tested by

no test coverage detected