MCPcopy Index your code
hub / github.com/cameri/nostream / parseEnvFile

Function parseEnvFile

src/cli/utils/env-config.ts:74–109  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72const SECRET_KEY_REGEX = /(SECRET|PASSWORD|API_KEY|PRIVATE_KEY)/i
73
74const parseEnvFile = (): { lines: string[]; parsed: ParsedEnvLine[] } => {
75 const envPath = getEnvFilePath()
76
77 if (!fs.existsSync(envPath)) {
78 return {
79 lines: [],
80 parsed: [],
81 }
82 }
83
84 const lines = fs.readFileSync(envPath, 'utf-8').split(/\r?\n/)
85 const parsed: ParsedEnvLine[] = []
86
87 for (let index = 0; index < lines.length; index += 1) {
88 const line = lines[index]
89 if (!line || line.trim().startsWith('#')) {
90 continue
91 }
92
93 const match = line.match(ENV_LINE_REGEX)
94 if (!match) {
95 continue
96 }
97
98 parsed.push({
99 index,
100 key: match[1],
101 value: match[2],
102 })
103 }
104
105 return {
106 lines,
107 parsed,
108 }
109}
110
111export const isSupportedEnvKey = (key: string): boolean => {
112 return SUPPORTED_ENV_KEYS.has(key) || RR_KEY_REGEX.test(key)

Callers 2

readEnvValuesFunction · 0.85
upsertEnvValueFunction · 0.85

Calls 1

getEnvFilePathFunction · 0.90

Tested by

no test coverage detected