MCPcopy Create free account
hub / github.com/Noumena-Network/code / clearCwdEnvFiles

Function clearCwdEnvFiles

src/utils/sessionEnvironment.ts:53–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51}
52
53export async function clearCwdEnvFiles(): Promise<void> {
54 try {
55 const dir = await getSessionEnvDirPath()
56 if (!dir) return
57 const files = await readdir(dir)
58 await Promise.all(
59 files
60 .filter(
61 f =>
62 (f.startsWith('filechanged-hook-') ||
63 f.startsWith('cwdchanged-hook-')) &&
64 HOOK_ENV_REGEX.test(f),
65 )
66 .map(f => writeFile(join(dir, f), '')),
67 )
68 } catch (e: unknown) {
69 const code = getErrnoCode(e)
70 if (code !== 'ENOENT') {
71 logForDebugging(`Failed to clear cwd env files: ${errorMessage(e)}`)
72 }
73 }
74}
75
76export function invalidateSessionEnvCache(): void {
77 logForDebugging('Invalidating session environment cache')

Callers 1

onCwdChangedForHooksFunction · 0.85

Calls 5

getSessionEnvDirPathFunction · 0.85
readdirFunction · 0.85
getErrnoCodeFunction · 0.85
logForDebuggingFunction · 0.70
errorMessageFunction · 0.70

Tested by

no test coverage detected