MCPcopy Index your code
hub / github.com/devcontainers/cli / updateUserEnvCache

Function updateUserEnvCache

src/spec-common/injectHeadless.ts:817–832  ·  view source on GitHub ↗
(env: Record<string, string>, userEnvProbe: UserEnvProbe, params: { output: Log; containerSessionDataFolder?: string }, shellServer?: ShellServer)

Source from the content-addressed store, hash-verified

815}
816
817async function updateUserEnvCache(env: Record<string, string>, userEnvProbe: UserEnvProbe, params: { output: Log; containerSessionDataFolder?: string }, shellServer?: ShellServer) {
818 if (!shellServer || !params.containerSessionDataFolder) {
819 return;
820 }
821
822 const cacheFile = getUserEnvCacheFilePath(userEnvProbe, params.containerSessionDataFolder);
823 try {
824 await shellServer.exec(`mkdir -p '${path.posix.dirname(cacheFile)}' && cat > '${cacheFile}' << 'envJSON'
825${JSON.stringify(env, null, '\t')}
826envJSON
827`);
828 }
829 catch (e) {
830 params.output.write(`Failed to cache user env: ${e}`, LogLevel.Error);
831 }
832}
833
834function getUserEnvCacheFilePath(userEnvProbe: UserEnvProbe, cacheFolder: string): string {
835 return path.posix.join(cacheFolder, `env-${userEnvProbe}.json`);

Callers 1

probeUserEnvFunction · 0.85

Calls 3

getUserEnvCacheFilePathFunction · 0.85
execMethod · 0.65
writeMethod · 0.65

Tested by

no test coverage detected